feat(cli,db,render): add row filters, cost sorting, run-rate projection, and CSV output - #9
Open
lorecanc wants to merge 1 commit into
Open
feat(cli,db,render): add row filters, cost sorting, run-rate projection, and CSV output#9lorecanc wants to merge 1 commit into
lorecanc wants to merge 1 commit into
Conversation
…on, and CSV output
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
Additive output/analysis features for
run:--provider,--model,--agent(all repeatable) and--exclude-provider. Implemented as aFiltersdataclass +_filter_clause()applied to every query (_base_query,by_agent,by_session,totals), parameterized SQL only.--sort tokens|cost|calls— sorts grouped rows by cost or calls instead of always tokens.≈ $X/mo(cost projected onto a 30-day month at the observed pace); also emitted asrun_rate_monthlyin JSON.--csv— row export to stdout (mutually exclusive with--json), with the agent view including the model column.Cross-PR note
The
Filtersdataclass is identical to the one introduced by the granularity PR (feat/time-granularities) so the hunks deduplicate at merge; the granularity PR'sby_time()already forwards a reservedfiltersparameter.Changes
src/opencode_usage/db.py:Filters,_filter_clause(), filter/sort params on_base_query,daily,by_model,by_provider,by_agent,by_session,totalssrc/opencode_usage/cli.py: filter/sort/csv flags,_build_filters,_compute_run_rate, JSONrun_rate_monthlysrc/opencode_usage/render.py: run-rate inrender_summary,render_csvtests/test_db.py,tests/test_cli.py: new tests (filters per query, exact-ID matching, sort order, flag parsing, exclusivity, run-rate math)README.md: documentedVerification
uv run pytest tests/— 390 passeduvx ruff check .anduvx ruff format --check .— clean