chore: post-merge polish for historic-analysis refactor#60
Merged
Conversation
Two minor follow-ups to the historic-analysis refactor merged in #53: - Hoist the loop-invariant `if user and ai_responses` check out of the per-AI-response loop in MetricsCalculator.calculate_daily_metrics. The user-token attribution now multiplies by len(ai_responses) once instead of repeating the test on every iteration; behaviour is unchanged. - Add a warning comment to mariadb-init/init.sql clarifying that the DROP DATABASE is only safe because mariadb-init runs exclusively on empty data directories — anyone running the file manually would wipe historical metrics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #53 — two minor cleanups that were noted in review but not blocking the merge:
MetricsCalculator.calculate_daily_metrics— hoist the loop-invariantif user and ai_responses:check out of the per-AI-response loop. The user-token attribution now multiplies bylen(ai_responses)once instead of repeating the test on every iteration. Behaviour is unchanged: when there are no AI responses or no user, nothing is added; otherwise the user receivestoken_count × Ninput tokens (matching the existing regeneration semantics).mariadb-init/init.sql— add a comment clarifying that the leadingDROP DATABASE IF EXISTSis only safe because the official MariaDB image runsmariadb-initscripts exclusively on first volume init. Anyone tempted tomysql < init.sqlagainst a populated volume would wipe their historical metrics; the warning makes that explicit.delete_future_dates()— flagged in review as defined-but-unused — was already removed during the merge, so no action needed there.The
.env-vs-.env.exampleconvention discussion was deliberately left out; that's a wider call.