Spaces:
Runtime error
Runtime error
fixed db issue
Browse files
db.py
CHANGED
@@ -3,7 +3,7 @@ from redis import Redis
|
|
3 |
from dotenv import load_dotenv
|
4 |
from uuid import uuid4
|
5 |
|
6 |
-
load_dotenv(".env
|
7 |
import os
|
8 |
import json
|
9 |
from redis.commands.json.path import Path
|
@@ -46,7 +46,9 @@ def create_user(client: Redis, user: User):
|
|
46 |
|
47 |
def get_user_by_username(client: Redis, username: str) -> Optional[User]:
|
48 |
uid = client.get(f"user:uuid:by-username:{username}")
|
49 |
-
user = client.json().get(f"user:by-uid:{uid}", "$")
|
|
|
|
|
50 |
return user
|
51 |
|
52 |
|
|
|
3 |
from dotenv import load_dotenv
|
4 |
from uuid import uuid4
|
5 |
|
6 |
+
load_dotenv(".env")
|
7 |
import os
|
8 |
import json
|
9 |
from redis.commands.json.path import Path
|
|
|
46 |
|
47 |
def get_user_by_username(client: Redis, username: str) -> Optional[User]:
|
48 |
uid = client.get(f"user:uuid:by-username:{username}")
|
49 |
+
user = client.json().get(f"user:by-uid:{uid}", "$")
|
50 |
+
if user:
|
51 |
+
user = user[0]
|
52 |
return user
|
53 |
|
54 |
|