1
0

Improved caching

This commit is contained in:
Jon Michael Aanes 2024-10-10 14:00:47 +02:00
parent 809956059b
commit e594dff149

View File

@ -115,9 +115,7 @@ class FavroClient:
next(self.get_todo_list_cards()) next(self.get_todo_list_cards())
def get_todo_list_cards(self) -> Iterator[Card]: def get_todo_list_cards(self) -> Iterator[Card]:
for card in self.get_cards(todo_list=True): yield from self.get_cards(todo_list=True)
self.card_cache.add_card(card)
yield card
def get_cards( def get_cards(
self, self,
@ -127,7 +125,9 @@ class FavroClient:
todo_list=False, todo_list=False,
) -> Iterator[Card]: ) -> Iterator[Card]:
request = self._get_cards_request(seq_id=seq_id,todo_list=todo_list,collection_id=collection_id) request = self._get_cards_request(seq_id=seq_id,todo_list=todo_list,collection_id=collection_id)
yield from self._get_paginated(request, Card.from_json) for card in self._get_paginated(request, Card.from_json):
self.card_cache.add_card(card)
yield card
def get_collections(self) -> Iterator[Collection]: def get_collections(self) -> Iterator[Collection]:
request = requests.Request('GET', URL_GET_COLLECTIONS) request = requests.Request('GET', URL_GET_COLLECTIONS)