Mohammedallyl commited on
Commit
c56bf06
1 Parent(s): b55f93a

Update Logic/Locations/GetMapOfuser.py

Browse files
Files changed (1) hide show
  1. Logic/Locations/GetMapOfuser.py +58 -58
Logic/Locations/GetMapOfuser.py CHANGED
@@ -10,66 +10,66 @@ class DataType(BaseModel):
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
 
 
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=list(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