diff --git a/db.py b/db.py index 06b5794..0a500ad 100644 --- a/db.py +++ b/db.py @@ -966,6 +966,15 @@ def spend_by_user_since(since_ts: float) -> dict: "rub_unknown": int(r["rub_unknown"] or 0)} for r in rows} +def list_account_entries(username: str, limit: int = 200) -> list[dict]: + with _conn() as conn: + rows = conn.execute( + "SELECT id, ts, amount_kop, comment, created_by, reverses " + "FROM account_entries WHERE username = ? ORDER BY id DESC LIMIT ?", + (username.lower().strip(), max(1, min(limit, 1000)))).fetchall() + return [dict(r) for r in rows] + + def account_summary(username: str) -> dict | None: """Взносы человека одной строкой: {"entries", "deposited_kop", "first_ts"}; None — взносов не было, человек не на счёте."""