-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
149 lines (119 loc) · 4.4 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import pyrebase
import func
import json
import summaryfunc
from datetime import datetime, timedelta
from math import radians, cos, sin, asin, sqrt
config = {
"apiKey": "AIzaSyDVe_UbuxI4Hw2LO-mfJWQfSKfNFmVYExE",
"authDomain": "fir-phoneauth1-1208a.firebaseapp.com",
"databaseURL":
"https://fir-phoneauth1-1208a-default-rtdb.asia-southeast1.firebasedatabase.app",
"projectId": "fir-phoneauth1-1208a",
"storageBucket": "fir-phoneauth1-1208a.appspot.com",
"messagingSenderId": "57907367912",
"appId": "1:57907367912:web:8812c804b2108d11701e5d",
"measurementId": "G-8VFK1RBCET"
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
#create user sessions
#db.child("users").child(717223652).update({
# "dob": "2517",
# "email": "[email protected]",
# "phone": "717223652",
# "name": "Anuradha"
#})
#db.child("history").child("776223913").child("20230525").child(1).child(6).set({"alt":1,"text":90})
#push data without number
#new_record = {"date": "2023053"}
#db.child("history").child("769246233").push(new_record)
#for item in query.each():
# print(item.key(),item.val())
# print("\n")
#db.child("history").child("769246233").child("20230523").update({"date":20230523})
#db.child("history").child("769246233").child("20230523").child(1).set(
#{"time": 80})
#func.update("users","0715843108","name","Sac")
#func.retreive("users","0715843108")
#db.child("users").child("0715843108").update({"name": "Rohini"})
#retreive
#users = db.child("User Table").child("0786779000").get()
#print(users.val())
#delete
#db.child("User Table").child("0786779000").child("Age").remove()
#test=func.retreivesummary("history","769246233","1","1")
#print(test)
#ashan codes
#test2=func.retr_user_session(db,'769246233')
#for item in test2.each():
# print(item.key(),item.val())
# print("\n")
#query=func.retreivesummary("history",'769246233')
#for item in query.each():
#print(item.key())
#print("\n")
#keys = func.retreivesummary("history", '769246233')
#for key in keys:
#print(key)
#print("\n")
#func.retrieve_only_alt("history", "769246233", "20230630","-NZ9yhXn5LvvNGsRiCOb")
#for item in query:
#print(item.key(), item.val())
#print("\n")
#func.retreivedate4("history", "769246233")
#func.retrieve_sessions_with_stime5("history", "769246233", "20230523")
#func.retreivesession2("history", "769246233","20230524")
#phone_number = input("Enter Phone number: ")
#exists = func.check_phone_number(phone_number)
#if exists:
# print("Phone number exists in the database")
#else:
# print("Phone number does not exist in the database")
#func.get_avg("769246233", "20230523", "1")
#func.get_avg1("769246233", "20230523", "1")
#func.get_avg2("769246233", "20230523", "1")
#func.retrieve_sessions_with_time("history","769246233","20230523")
#user="769246233"
#date="20230701"
#session="-NZGh-Lp-wYMwrxv5LMm"
#summaryfunc.summary(db,user,date,session)
#db.child("history").child("769246233").child("20230523").child(1).update({"result":result})
#func.test("history","769246233")
#func.retrive_timenew2("history","769246233","20230523")
#summaryfunc.summary("history", "769246233", "20230630","-NZ9yhXn5LvvNGsRiCOb")
#func.timeduration2(datetime)
#def distance(lat1, lat2, lon1, lon2):
# The math module contains a function named
# radians which converts from degrees to radians.
#lon1 = radians(lon1)
#lon2 = radians(lon2)
#lat1 = radians(lat1)
#lat2 = radians(lat2)
# Haversine formula
#dlon = lon2 - lon1
#dlat = lat2 - lat1
#a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
#c = 2 * asin(sqrt(a))
# Radius of earth in kilometers. Use 3956 for miles
#r = 6371
# calculate the result
#return (c * r)
# driver code
#lat1 = 53.32055555555556
#lat2 = 53.31861111111111
#lon1 = -1.7297222222222221
#lon2 = -1.6997222222222223
#print(distance(lat1, lat2, lon1, lon2), "K.M")
#func.distance(db,"769246233", "20230630", "-NZ9yhXn5LvvNGsRiCOb")
#func. retreive_user_data(db,"users","706502465")
#db.child("users").child("706502465").set(
#{"name":"Sachini"})
#db.child("users").child("715843108").update({"timeinterval": "5"})
#db.child("users").child("715843108").child("time interval").remove()
previous_session_data = func.get_previous_session_data_after_alt_2(db, "769246233", "20230630", "-NZ9yhXn5LvvNGsRiCOb")
if previous_session_data:
# Use the "alt" value and the data after the "alt" key in the previous session data as needed
print(previous_session_data)
else:
print("No previous session data found or 'alt' key not present.")