Skip to content

Commit 37ab5a7

Browse files
maximum optmization for fast api
1 parent 83a8494 commit 37ab5a7

File tree

8 files changed

+139
-127
lines changed

8 files changed

+139
-127
lines changed
1.13 KB
Binary file not shown.

API/DATABASE/get_data.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def uid_by_email(EMAIL):
136136

137137
def uid_by_cookie(COOKIE):
138138
try:
139+
uid = None
139140
connection = database.connect_users_db()
140141
if connection:
141142
cursor = connection.cursor()
@@ -144,12 +145,13 @@ def uid_by_cookie(COOKIE):
144145
SELECT UID FROM users WHERE COOKIE=?
145146
""", (COOKIE,))
146147

147-
uid = cursor.fetchone()
148+
row = cursor.fetchone()
149+
uid = row[0] if row else None
148150
cursor.close()
149-
return uid[0]
151+
return uid
150152
except Exception as e:
151153
print("err on uid_by_cookie(COOKIE):", e)
152-
return False
154+
return None
153155
finally:
154156
if connection:
155157
connection.close()
@@ -173,9 +175,7 @@ def uid_by_token(TOKEN):
173175
finally:
174176
if connection:
175177
connection.close()
176-
177-
178-
178+
179179
def token(COOKIE):
180180
try:
181181
connection = database.connect_users_db()
@@ -193,6 +193,26 @@ def token(COOKIE):
193193
finally:
194194
if connection:
195195
connection.close()
196+
197+
def profile_pic(*,UID=None,GUID=None):
198+
connection = None
199+
profile_pic = 'NOT FOUND'
200+
try:
201+
connection = database.connect_users_db() if UID else database.connect_chats_db() if GUID else None
202+
if connection:
203+
cursor = connection.cursor()
204+
table, uid_or_guid = ('users', 'UID') if UID else ('Groups_credentials', 'GUID')
205+
cursor.execute(f"""
206+
SELECT PROFILE_PIC FROM {table} WHERE {uid_or_guid} = ?
207+
""", (UID or GUID,))
208+
row = cursor.fetchone()
209+
profile_pic = row[0] if row else "NO PROFILE FIC FOUNDD"
210+
return profile_pic
211+
except Exception as e:
212+
return e
213+
finally:
214+
if connection:
215+
connection.close()
196216

197217
def first_name(RAW_UID):
198218
UID = int(RAW_UID)
9 Bytes
Binary file not shown.

API/GENERAL/send_verification_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
Thanks for being part of the Mesaanger -Ax community! 💼
3030
3131
Stay safe,
32-
Messanger - Ax
32+
<h1>Messanger - Ax</h1>
3333
3434
---
3535

DB/all_users.db

0 Bytes
Binary file not shown.

DB/chats_lists.db

4 KB
Binary file not shown.

DB/messages.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)