Spaces:
Sleeping
Sleeping
Update dependencies/database.py
Browse files- dependencies/database.py +9 -18
dependencies/database.py
CHANGED
@@ -33,13 +33,14 @@ class SupabaseDb:
|
|
33 |
except Exception as e:
|
34 |
print(f"Error occured : {e}")
|
35 |
|
36 |
-
def insert_tokens_v1(self,access_token: str, refresh_token: str, hushh_id: str):
|
37 |
supabase = self.supabase_client()
|
38 |
# First, check if a row with the given hushh_id exists
|
39 |
existing_row = (
|
40 |
supabase.table("receipt_radar_history")
|
41 |
.select("*")
|
42 |
-
.eq("hushh_id", hushh_id)
|
|
|
43 |
.execute()
|
44 |
)
|
45 |
if existing_row.data:
|
@@ -50,7 +51,8 @@ class SupabaseDb:
|
|
50 |
"access_token": access_token,
|
51 |
"refresh_token": refresh_token
|
52 |
})
|
53 |
-
.eq("hushh_id", hushh_id)
|
|
|
54 |
.execute()
|
55 |
)
|
56 |
print("Updating the access and refresh tokens for existing hushh_id")
|
@@ -61,7 +63,8 @@ class SupabaseDb:
|
|
61 |
.insert({
|
62 |
"access_token": access_token,
|
63 |
"refresh_token": refresh_token,
|
64 |
-
"hushh_id": hushh_id
|
|
|
65 |
})
|
66 |
.execute()
|
67 |
)
|
@@ -69,21 +72,9 @@ class SupabaseDb:
|
|
69 |
|
70 |
print(response)
|
71 |
return response
|
|
|
|
|
72 |
|
73 |
-
def insert_tokens(self,access_token:str,refresh_token:str,hushh_id:str,email:str):
|
74 |
-
supabase = self.supabase_client()
|
75 |
-
response = (
|
76 |
-
supabase.table("receipt_radar_history")
|
77 |
-
.update({"access_token": access_token,"refresh_token":refresh_token})
|
78 |
-
.eq("hushh_id",hushh_id)
|
79 |
-
.eq("email",email)
|
80 |
-
.execute()
|
81 |
-
)
|
82 |
-
print("Inserting the access and refresh tokens")
|
83 |
-
print(response)
|
84 |
-
|
85 |
-
|
86 |
-
def insert_tokens_temp(self,access_token:str,refresh_token:str,hushh_id:str):
|
87 |
supabase = self.supabase_client()
|
88 |
response = (
|
89 |
supabase.table("receipt_radar_history")
|
|
|
33 |
except Exception as e:
|
34 |
print(f"Error occured : {e}")
|
35 |
|
36 |
+
def insert_tokens_v1(self,access_token: str, refresh_token: str, hushh_id: str,email:str):
|
37 |
supabase = self.supabase_client()
|
38 |
# First, check if a row with the given hushh_id exists
|
39 |
existing_row = (
|
40 |
supabase.table("receipt_radar_history")
|
41 |
.select("*")
|
42 |
+
.eq("hushh_id", hushh_id)
|
43 |
+
.eq("email",email)
|
44 |
.execute()
|
45 |
)
|
46 |
if existing_row.data:
|
|
|
51 |
"access_token": access_token,
|
52 |
"refresh_token": refresh_token
|
53 |
})
|
54 |
+
.eq("hushh_id", hushh_id)
|
55 |
+
.eq("hushh_id",email)
|
56 |
.execute()
|
57 |
)
|
58 |
print("Updating the access and refresh tokens for existing hushh_id")
|
|
|
63 |
.insert({
|
64 |
"access_token": access_token,
|
65 |
"refresh_token": refresh_token,
|
66 |
+
# "hushh_id": hushh_id
|
67 |
+
|
68 |
})
|
69 |
.execute()
|
70 |
)
|
|
|
72 |
|
73 |
print(response)
|
74 |
return response
|
75 |
+
|
76 |
+
def insert_tokens(self,access_token:str,refresh_token:str,hushh_id:str):
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
supabase = self.supabase_client()
|
79 |
response = (
|
80 |
supabase.table("receipt_radar_history")
|