Get database statistics
(self)
| 270 | return deleted_count |
| 271 | |
| 272 | def get_stats(self) -> Dict: |
| 273 | """Get database statistics""" |
| 274 | conn = sqlite3.connect(self.db_path) |
| 275 | |
| 276 | # Get session count |
| 277 | cursor = conn.execute('SELECT COUNT(*) FROM sessions') |
| 278 | session_count = cursor.fetchone()[0] |
| 279 | |
| 280 | # Get message count |
| 281 | cursor = conn.execute('SELECT COUNT(*) FROM messages') |
| 282 | message_count = cursor.fetchone()[0] |
| 283 | |
| 284 | # Get most used model |
| 285 | cursor = conn.execute(''' |
| 286 | SELECT model_used, COUNT(*) as count |
| 287 | FROM sessions |
| 288 | GROUP BY model_used |
| 289 | ORDER BY count DESC |
| 290 | LIMIT 1 |
| 291 | ''') |
| 292 | most_used_model = cursor.fetchone() |
| 293 | |
| 294 | conn.close() |
| 295 | |
| 296 | return { |
| 297 | "total_sessions": session_count, |
| 298 | "total_messages": message_count, |
| 299 | "most_used_model": most_used_model[0] if most_used_model else None |
| 300 | } |
| 301 | |
| 302 | def add_document_to_session(self, session_id: str, file_path: str) -> int: |
| 303 | """Adds a document file path to a session.""" |
no outgoing calls
no test coverage detected