@@ -81,9 +81,6 @@ class UltraDictType[K, V](MutableMapping[K, V], abc.ABC):
8181 UltraDict (buffer_size = 1024 ** 2 , serializer = dill )
8282)
8383
84- MAX_QUOTES_ID = Value ("Q" , 0 )
85- MAX_AUTHORS_ID = Value ("Q" , 0 )
86-
8784
8885@dataclass (init = False , slots = True )
8986class QuotesObjBase (abc .ABC ):
@@ -437,7 +434,6 @@ def parse_author(json_data: Mapping[str, Any]) -> Author:
437434 if author is None :
438435 # pylint: disable-next=too-many-function-args
439436 author = Author (id_ , name , None )
440- MAX_AUTHORS_ID .value = max (MAX_AUTHORS_ID .value , id_ )
441437 elif author .name != name :
442438 author .name = name
443439 author .info = None # reset info
@@ -474,7 +470,6 @@ def parse_quote(
474470 if quote is None : # new quote
475471 # pylint: disable=too-many-function-args
476472 quote = Quote (quote_id , quote_str , author .id )
477- MAX_QUOTES_ID .value = max (MAX_QUOTES_ID .value , quote .id )
478473 else : # quote was already saved
479474 quote .quote = quote_str
480475 quote .author_id = author .id
@@ -795,12 +790,12 @@ async def get_rating_by_id(quote_id: int, author_id: int) -> int | None:
795790
796791def get_random_quote_id () -> int :
797792 """Get random quote id."""
798- return random .randint ( 1 , MAX_QUOTES_ID . value ) # nosec: B311
793+ return random .choice ( tuple ( QUOTES_CACHE ))
799794
800795
801796def get_random_author_id () -> int :
802797 """Get random author id."""
803- return random .randint ( 1 , MAX_AUTHORS_ID . value ) # nosec: B311
798+ return random .choice ( tuple ( AUTHORS_CACHE ))
804799
805800
806801def get_random_id () -> tuple [int , int ]:
0 commit comments