docs: document history store helpers

This commit is contained in:
nyan404 committed 2026-08-25 04:19:27 +03:00
1 parent 09be5d5969
commit 9d2abde1a5
1 file changed
+2
+2
View File
@@ -43,6 +43,7 @@ class CalculationStore:
@classmethod @classmethod
def from_environment(cls) -> "CalculationStore": def from_environment(cls) -> "CalculationStore":
"""Создаёт хранилище, выбрав PostgreSQL или SQLite по окружению."""
return cls( return cls(
database_url=os.getenv("BELKI_DATABASE_URL"), database_url=os.getenv("BELKI_DATABASE_URL"),
sqlite_path=os.getenv("BELKI_HISTORY_DB", "data/belki.sqlite3"), sqlite_path=os.getenv("BELKI_HISTORY_DB", "data/belki.sqlite3"),
@@ -155,6 +156,7 @@ class CalculationStore:
if sort_by not in {"escort_id", "escort_name", "kitten_id", "kitten_name"}: if sort_by not in {"escort_id", "escort_name", "kitten_id", "kitten_name"}:
sort_by = "escort_id" sort_by = "escort_id"
def sort_value(item: dict[str, Any]) -> tuple[bool, int, int | str]: def sort_value(item: dict[str, Any]) -> tuple[bool, int, int | str]:
"""Строит ключ, который сортирует числовые и текстовые значения предсказуемо."""
data = item["input"] data = item["input"]
if sort_by == "escort_id": if sort_by == "escort_id":
value = data.get("escort_id", data.get("character_id")) value = data.get("escort_id", data.get("character_id"))