Spaces:
Sleeping
Sleeping
Update Logic/Locations/GetMapOfuser.py
Browse files- Logic/Locations/GetMapOfuser.py +56 -55
Logic/Locations/GetMapOfuser.py
CHANGED
|
@@ -10,65 +10,66 @@ class DataType(BaseModel):
|
|
| 10 |
|
| 11 |
@UserGetLocationRouter.post("/GetMapLocations")
|
| 12 |
def adduser(Data:DataType):
|
| 13 |
-
try:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
cursor=connect.execute(f'''
|
| 24 |
-
SELECT
|
| 25 |
''')
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# SELECT AVG(Longtude) , AVG(Lattitude) TrackeringPoints WHERE Day='{Day}' and UserId={UserId}
|
| 40 |
-
# ''')
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
# PositionsMean=cursor2.fetchall()
|
| 44 |
-
connect.close()
|
| 45 |
-
if len(DataCollected)==0:
|
| 46 |
-
return {
|
| 47 |
-
"Status":True,
|
| 48 |
-
"Data":{
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 54 |
}
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
"Data":{
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
}
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
return {"Status":False,"Message":e}
|
| 74 |
|
|
|
|
| 10 |
|
| 11 |
@UserGetLocationRouter.post("/GetMapLocations")
|
| 12 |
def adduser(Data:DataType):
|
| 13 |
+
# try:
|
| 14 |
+
Email=Data.Email
|
| 15 |
+
Password=Data.Password
|
| 16 |
+
Day=Data.Day
|
| 17 |
+
State=False
|
| 18 |
+
|
| 19 |
+
# pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
connect=sqlite3.connect("DataBase/DataBase.bd")
|
| 23 |
+
cursor=connect.execute(f'''
|
| 24 |
+
SELECT UserId,Password FROM Users where Email='{Email}'
|
| 25 |
+
''')
|
| 26 |
+
Data=cursor.fetchall()
|
| 27 |
+
if len(Data) !=0 :
|
| 28 |
+
if Data[0][0]==None:
|
| 29 |
+
return {"Status":False,"Message":"User Is Not Defined Before"}
|
| 30 |
+
HasedPassword=Data[0][1]
|
| 31 |
+
UserId=Data[0][0]
|
| 32 |
+
State=Password==HasedPassword
|
| 33 |
+
if State:
|
| 34 |
cursor=connect.execute(f'''
|
| 35 |
+
SELECT Longtude , Lattitude,Houre FROM TrackeringPoints WHERE Day='{Day}' and UserId={UserId}
|
| 36 |
''')
|
| 37 |
+
DataCollected=cursor.fetchall()
|
| 38 |
+
# cursor2=connect.execute(f'''
|
| 39 |
+
# SELECT AVG(Longtude) , AVG(Lattitude) TrackeringPoints WHERE Day='{Day}' and UserId={UserId}
|
| 40 |
+
# ''')
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# PositionsMean=cursor2.fetchall()
|
| 44 |
+
connect.close()
|
| 45 |
+
print(DataCollected)
|
| 46 |
+
if len(DataCollected)==0:
|
| 47 |
+
return {
|
| 48 |
+
"Status":True,
|
| 49 |
+
"Data":{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
"PositionData":[],
|
| 52 |
+
"Time":[],
|
| 53 |
+
"Mean":[51.505, -0.09]
|
| 54 |
+
|
| 55 |
+
}
|
| 56 |
}
|
| 57 |
+
PositionData=[ [ item[0],item[1]]for item in DataCollected]
|
| 58 |
+
PositionsMean=mean(array(PositionData),axis=0)
|
| 59 |
+
Houre=[ item[2] for item in DataCollected]
|
| 60 |
+
|
| 61 |
+
return {
|
| 62 |
+
"Status":True,
|
| 63 |
+
"Data":{
|
|
|
|
| 64 |
|
| 65 |
+
"PositionData":PositionData,
|
| 66 |
+
"Time":Houre,
|
| 67 |
+
"Mean":PositionsMean
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
}
|
| 71 |
+
else:
|
| 72 |
+
return {"State":False}
|
| 73 |
+
# except Exception as e :
|
| 74 |
+
# return {"Status":False,"Message":e}
|
|
|
|
| 75 |
|