refactor(llm): centralize usage persistence
This commit is contained in:
@@ -12,6 +12,16 @@ class LLMRepository:
|
||||
).fetchone()
|
||||
return int(row["successful_calls"]) if row else 0
|
||||
|
||||
@staticmethod
|
||||
def usage_for_users(connection: sqlite3.Connection, usage_date: str) -> dict[int, int]:
|
||||
return {
|
||||
int(row["user_id"]): int(row["successful_calls"])
|
||||
for row in connection.execute(
|
||||
"SELECT user_id, successful_calls FROM llm_usage_daily WHERE usage_date = ?",
|
||||
(usage_date,),
|
||||
)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def active_today(connection: sqlite3.Connection, user_id: int, day_prefix: str) -> int:
|
||||
row = connection.execute(
|
||||
|
||||
Reference in New Issue
Block a user