Append-only event recording for usage statistics, plus read-side queries.
Folder layout
stats/
mod.rs ← this file: module wiring + public re-exports
events.rs ← write-side: record_command, record_branch_event,
record_commit, record_workspace_event, record_stack_event,
record_commit_message, import_git_history
queries.rs ← read-side aggregations: OverallStats, query_overall,
top_commands, commit_type_counts, top_repos_by_activity,
activity_by_hour, streak_info
messages.rs ← commit-message queries: search, duplicates, length stats,
monthly trends, top authors
Conventions
- All
record_*functions are designed to be called with.ok()— a stats write failure must never abort the user’s actual operation. - All
query_*/top_*/streak_info/activity_by_hourhelpers are read-only and tolerant of missing or empty tables: a failing query returns the zero value rather than an error so the rest of the report keeps rendering.
Every public symbol below is re-exported under crate::storage::stats::*
so call sites continue to write use crate::storage::stats as db; and
db::top_commands(…) without caring about the split.
Source:
src/storage/stats/mod.rs