fix: sort admin reports by newest date
This commit is contained in:
1 parent
4bf520fb42
commit
a15c22b4a2
5 files changed
+22
-4
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import tempfile
|
||||
import unittest
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
from app.belki.history import CalculationStore
|
||||
@@ -50,6 +51,17 @@ class CalculationHistoryTests(unittest.TestCase):
|
||||
rows = store.list_calculations(sort_by="kitten_id", descending=False)
|
||||
self.assertEqual([row["input"]["kitten_id"] for row in rows], [2, "12", "not-an-id"])
|
||||
|
||||
def test_admin_history_sorts_by_creation_date_newest_first(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = CalculationStore(sqlite_path=Path(directory) / "history.sqlite3")
|
||||
first = store.save(actor_id=1, source="web", payload={"mode": "coaching"}, response={"message": "old", "result": {}})
|
||||
second = store.save(actor_id=2, source="web", payload={"mode": "coaching"}, response={"message": "new", "result": {}})
|
||||
with sqlite3.connect(store.sqlite_path) as connection:
|
||||
connection.execute("UPDATE calculations SET created_at=? WHERE id=?", ("2026-10-10 10:00:00", first))
|
||||
connection.execute("UPDATE calculations SET created_at=? WHERE id=?", ("2026-10-10 11:00:00", second))
|
||||
rows = store.list_calculations(sort_by="created_at", descending=True)
|
||||
self.assertEqual([row["id"] for row in rows], [second, first])
|
||||
|
||||
def test_admin_history_backfills_legacy_inspection_breakdown(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = CalculationStore(sqlite_path=Path(directory) / "history.sqlite3")
|
||||
|
||||
Reference in new issue
Block a user