feat: get_id_of_latest_haiku instead of load_latest_haiku

Refs: OP-22
This commit is contained in:
Christoph J. Scherr 2025-02-25 17:56:01 +01:00
parent e700771c53
commit 4ce43ec54d
No known key found for this signature in database
GPG key ID: 9EB784BB202BB7BB

View file

@ -42,10 +42,10 @@ class StoreManager:
def save_haiku(self, data: Haiku) -> int:
return self._save(data.__dict__)
def load_latest_haiku(self) -> Optional[Haiku]:
def get_id_of_latest_haiku(self) -> Optional[int]:
try:
id = self._db.all()[-1].doc_id
self.load_haiku(id)
return id
except IndexError as e:
self.logger.error(f"The database seems to be empty: {e}")
return None