Added get and search kahoot-thing

This commit is contained in:
Mawoka
2022-03-08 21:20:53 +01:00
parent 449f227ecc
commit 5c5386fdf8
8 changed files with 313 additions and 126 deletions
+4 -4
View File
@@ -14,14 +14,14 @@ async def cache_account(criteria: str, content: str) -> Union[User, None]:
if criteria == "email":
try:
res = await User.objects.get(email=content, verified=True)
res = await User.objects.search()
except ormar.exceptions.NoMatch:
return None
await insert_into_redis(res, content)
return res
elif criteria == "username":
try:
res = await User.objects.get(username=content, verified=True)
res = await User.objects.search()
except ormar.exceptions.NoMatch:
return None
await insert_into_redis(res, content)
@@ -29,7 +29,7 @@ async def cache_account(criteria: str, content: str) -> Union[User, None]:
elif criteria == "id":
try:
res = await User.objects.get(id=uuid.UUID(content), verified=True)
res = await User.objects.search()
except ormar.exceptions.NoMatch:
return None
await insert_into_redis(res, content)
@@ -39,7 +39,7 @@ async def cache_account(criteria: str, content: str) -> Union[User, None]:
async def get_from_redis(key: str) -> Union[None, User]:
user = await redis.get(key)
user = await redis.search(key)
if user is None:
return None
else: