feat: add 'lrc stats' command for review history (#60)#130
Conversation
|
Hi @iconicvenom - I made a detailed response here, which I think you missed as I moved the issue to discussions (sorry my bad, I should have mentioned it in the issue thread as well). Please take a look at this comment and what you think: #127 (comment) |
|
Converting this to a draft for now. 🙏 (btw it was my first pr took almost 3hr! 😭). Shape I'm proposing: extract git log into review records {hash, author, date, branch, action, iter, coverage} → filter (author/date/main...feature/path) → aggregate → output On the engine: the project already ships modernc.org/sqlite (pure Go, no CGO). I think we can get the same "query everything + aliases" by loading records into an in-memory SQLite table — without DuckDB's CGO/binary cost. Open to DuckDB if you prefer its analytics ergonomics. A few questions to settle scope:
Want me to move this to a Discussion since we're still scoping? |
|
Hi, Thanks for your enthusiasm in contributing to git-lrc.
This should store the query in Then user can run: And get results. Also we can have: to get JSON output. Hopefully this gives you an idea of how to make this extensible. Check the installer scripts - where we can ship with some default aliases for Hopefully this gives you a bit of direction. We can refine as we proceed further. Also, we need a few more "obvious" commands like: etc |
Adds 'lrc query', a read-only engine that builds an in-memory SQLite table of the repo's review history (parsed from commit trailers) and runs SQL or saved aliases against it. - lrc query [stats]: default summary (reviewed/vouched/skipped) - lrc query "<sql>": arbitrary SQL over the review_log table - lrc query <alias> [--json]: run a saved alias; table or JSON output - lrc query --add "<sql>" --name <n>: save an alias to ~/.lrc/queries.toml - lrc query list | view <n> | delete <n> Pure-Go SQLite (modernc.org/sqlite), no CGO/DuckDB dependency. All file and SQL I/O goes through storage/ so the architecture boundary test passes. Default aliases shipped via the installer scripts. Unit tests cover trailer parsing, record extraction, and output formatting. LiveReview Pre-Commit Check: skipped (iter:1, coverage:0%)
09f761d to
029ea2f
Compare
|
Updated this PR to implement the query engine we landed on in the thread, rather than the original single stats command. 🙌 @shrsv Summary of what's here now:
What this doesEvolves #60 from a single Usagelrc query # default 'stats' summary review_log columns: Design notes
TestsUnit tests for trailer parsing, git-log record extraction, and table/JSON
|
|
Hi @iconicvenom, took a quick look.
Also |
- query --help now documents the review_log schema (columns + types) and includes runnable example queries (incident forensics, per-author, coverage) - storage.BulkInsert: load rows in one transaction + prepared statement (far faster than per-row autocommit on large repos) - split RunOnRecords out of Run so the engine is testable/benchmarkable without git; add correctness tests + a scaling benchmark - installer query-file write is already idempotent (guarded by file-exists) LiveReview Pre-Commit Check: skipped (iter:1, coverage:0%)
|
Thanks for the review! Addressed all three:
So ≈1.5 µs and ≈940 bytes per commit (plus the git log read, which is I/O-bound). A 100k-commit repo is ~150 ms / ~95 MB in memory. If that ever becomes a concern, the easy Pushed as a follow-up commit. Let me know what else you'd like! |
|
I think you can implement that scan bounding option as well, just in case. Linux kernels has 1.5 million commits for example (so 10x of what you've shown here). And there are larger repos than that as well. So range bounding is a good idea like |
Bounds the git log scan so huge histories (e.g. Linux kernel, ~1.5M commits) aren't walked in full. --from/--to accept any git date; --range takes a ref range (e.g. main...feature) which also serves per-PR stats. Flags work before or after the positional arg. LiveReview Pre-Commit Check: skipped (iter:1, coverage:0%)
|
Added scan-bounding as suggested 👍
So on something like the Linux kernel (~1.5M commits) you can run lrc query stats --from "1 year ago" (or a --range) and only walk that slice instead of the full history. Added a unit test for the flag parsing and an example in --help. Pushed as a follow-up commit (d5b9bf3). |

Closes #60.
Adds a read-only
lrc statscommand that parses theLiveReview Pre-Commit Check:trailer from
git logand prints a per-repo summary (reviewed/vouched/skipped,with average iterations & coverage). Supports
--last N(days) and--json.I have read and accepted the Contributor License Agreement.