mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Fix random handlers
This commit is contained in:
@@ -315,7 +315,7 @@ class GetRandomService(Generic[MODEL, QUERY], BaseService[MODEL, QUERY]):
|
||||
cls,
|
||||
query: QUERY,
|
||||
redis: aioredis.Redis,
|
||||
) -> int:
|
||||
) -> int | None:
|
||||
cached_object_id = await cls._get_random_object_from_cache(query, redis)
|
||||
|
||||
if cached_object_id is not None:
|
||||
@@ -325,6 +325,9 @@ class GetRandomService(Generic[MODEL, QUERY], BaseService[MODEL, QUERY]):
|
||||
|
||||
await cls.cache_object_ids(query, object_ids, redis)
|
||||
|
||||
if len(object_ids):
|
||||
return None
|
||||
|
||||
return choice(object_ids)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user