Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions historic-analysis/export_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ def calculate_daily_metrics(self, messages, conversations):
user_msg_id = message.get('messageId')
user = message.get('user')
ai_responses = self._ai_responses_by_parent.get(user_msg_id, ())

for ai_msg in ai_responses:
tokens_by_model[ai_msg['model']]['input'] += token_count
if user and ai_responses:
tokens_by_user[user]['input'] += token_count
if user:
tokens_by_user[user]['input'] += token_count * len(ai_responses)

elif message.get('model'):
tokens_by_model[model_name]['output'] += token_count
Expand Down
6 changes: 5 additions & 1 deletion historic-analysis/mariadb-init/init.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
-- Drop and recreate database
-- WARNING: this script is intended for first-time MariaDB volume init only.
-- The `mariadb-init` directory is executed by the official MariaDB image
-- exclusively when the data directory is empty, so it is safe in that
-- context. Do NOT run this manually against a populated volume — it will
-- DROP the metrics database and wipe all historical data.
DROP DATABASE IF EXISTS metrics;
CREATE DATABASE metrics;
CREATE USER IF NOT EXISTS 'metrics'@'%' IDENTIFIED BY 'metrics';
Expand Down