Commit graph

10 commits

Author SHA1 Message Date
8037706f0b fix(db.py): remove full table scans with proper where clauses for dashboard statistics and calc in db rather than python 2026-03-03 17:20:33 +01:00
3af166c8a4 fix sqlite3.OperationalError: no such table: main.token_time_series 2026-02-11 13:46:37 +01:00
067cdf641a feat: add timestamp index and improve cache concurrency
- Added index on token_time_series timestamp for faster queries
- Introduced cache locks to prevent race conditions
2026-01-16 16:47:24 +01:00
34d6abd28b refactor: optimize token aggregation query and enhance chat proxy
- Refactored token aggregation query in db.py to use a single SQL query with SUM() instead of iterating through rows, improving performance
- Combined import statements in db.py and router.py to reduce lines of code
- Enhanced chat proxy in router.py to handle "moe-" prefixed models with multiple query execution and critique generation
- Added last_user_content() helper function to extract user content from messages
- Improved code readability and maintainability through these structural changes
2025-12-13 11:58:49 +01:00
59a8ef3abb refactor: use a persistent WAL-enabled connection with async locks
- Introduce a lazily initialized, shared aiosqlite connection stored in self._db and two asyncio locks (_db_lock, _operation_lock) for safe concurrent access
- Ensure the database directory exists before connecting and enable WAL journaling and foreign keys on first connect
- Add close method to gracefully close the persistent connection
- Guard initialization and write operations with _operation_lock to ensure single-threaded schema setup
- Switch to ON CONFLICT UPSERT for token_counts updates and initialize token_time_series table
- Add typing for _db (Optional[aiosqlite.Connection]) and adjust imports accordingly

addition: Frontend button with total stats aggregation task and feedback span element to keep user informed and a small database footprint
2025-12-02 12:18:23 +01:00
7b50a5a299 adding usage metrics to /v1 endpoints if stream == True 2025-11-21 09:56:42 +01:00
45d1d442ee sqlite: adding connection pooling and WAL 2025-11-20 15:37:04 +01:00
e0c6861f2f aggregating token_counts for stats over all endpoints and adjusting the color mapping 2025-11-20 09:22:45 +01:00
541f2826e0 fixing token_queue, prepping chart view 2025-11-18 19:02:36 +01:00
baf5d98318 adding token timeseries counting in db for future data viz 2025-11-18 11:16:21 +01:00