Expand description
SQL query builders for analytics.
All functions accept a &frankensqlite::Connection and an AnalyticsFilter,
keeping the SQL and bucketing logic in one place for both CLI and ftui.
Functions§
- build_
where_ parts - Build SQL WHERE clause fragments and bind-parameter values from an
AnalyticsFilter’s dimensional (non-time) filters. - query_
breakdown - Run a breakdown query: aggregate one metric by a chosen dimension.
- query_
cost_ timeseries - query_
session_ scatter - Query per-session
(message_count, api_tokens_total)points for Explorer scatter plots. - query_
status - Run the analytics status query — returns table health, coverage, and drift.
- query_
tokens_ timeseries - Run the token/usage timeseries query with the given bucketing granularity.
- query_
tools - query_
unpriced_ models - Query
token_usagefor model names that haveestimated_cost_usd IS NULL, grouped by model_name with total token counts. Returns the toplimitunpriced models sorted by total_tokens descending. - table_
exists - Check whether a table exists in the database.