diff options
Diffstat (limited to 'velascobot2/database.py')
| -rw-r--r-- | velascobot2/database.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/velascobot2/database.py b/velascobot2/database.py index 582495f..8be2b8c 100644 --- a/velascobot2/database.py +++ b/velascobot2/database.py @@ -154,6 +154,20 @@ class Database: return rows + def get_chat_vocab_count(self, chat_id: str) -> int: + with _SQLiteContextMgr(database=self.db_name) as db: + result = db.execute( + "SELECT SUM(count) FROM vocab WHERE chat_id = ?", (chat_id,) + ).fetchone()[0] + return result or 0 + + def get_chat_graph_count(self, chat_id: str) -> int: + with _SQLiteContextMgr(database=self.db_name) as db: + result = db.execute( + "SELECT SUM(count) FROM graphics WHERE chat_id = ?", (chat_id,) + ).fetchone()[0] + return result or 0 + def get_graphics(self, chat_id: str): with _SQLiteContextMgr(database=self.db_name) as db: rows = db.execute( |
