feat(cli,db): add minute/hour/week/month granularities and --weeks/--months windows - #8
Open
lorecanc wants to merge 1 commit into
Open
feat(cli,db): add minute/hour/week/month granularities and --weeks/--months windows#8lorecanc wants to merge 1 commit into
lorecanc wants to merge 1 commit into
Conversation
…months time windows
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
Extends the daily breakdown into a full set of time buckets and adds week/month time windows:
--by minute|hour|week|month(in addition today) via a newOpenCodeDB.by_time()query (SQLitestrftimewithlocaltime; labels like2026-08-05 16:00,2026-W31,2026-08).daily()is kept as a compatibility alias.--weeks N/--months Non bothrunandinsights(month = 30 days, matching themunit of--since). Precedence:--since>--days>--weeks/--months.Cross-PR note
by_time()accepts a reservedfiltersparameter that forwards to the query layer once row filters land (PRfeat/filters-and-output); it is inert here. TheFiltersdataclass in this PR is identical to the one in that PR, so git deduplicates it at merge time.Changes
src/opencode_usage/db.py:_TIME_FORMATS,by_time(),Filters(plumbing)src/opencode_usage/cli.py:--weeks/--months, extended--bychoices,_resolve_sinceprecedencesrc/opencode_usage/render.py:render_time()with per-granularity labels;render_daily()kept as an aliastests/test_db.py,tests/test_cli.py: new tests (bucket label formats, fallback, flag parsing, precedence)README.md: documentedVerification
uv run pytest tests/— 384 passeduvx ruff check .anduvx ruff format --check .— clean