Skip to content

refactor: share query stats rendering - #303

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/query-stats-contracts
Apr 21, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/query-stats-contracts

Conversation

@Sinity

@Sinity Sinity commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds shared grouped-stats table rendering for query stats surfaces.
  • Reuses common date/provider grouping helpers across summary, conversation, semantic, and profile-backed stats.
  • Preserves existing public function names and structured output payloads.

Problem

polylogue/cli/query_stats.py repeated the same group sorting, Rich table construction, total-row rendering, and semantic grouping loops across several stats paths. That made the surface harder to review and easy to drift when changing output contracts.

Solution

  • Introduce typed internal helpers for grouped stats payloads, date/provider grouping keys, and table rendering.
  • Route summary/date/provider stats, in-memory grouped conversation stats, semantic action/tool stats, and profile-backed stats through the shared renderer.
  • Keep SQL archive stats and exported function names stable for existing call sites.

Ref #270

Verification

  • ruff format polylogue/cli/query_stats.py
  • ruff check polylogue/cli/query_stats.py
  • mypy polylogue/cli/query_stats.py tests/unit/cli/test_query_exec_laws.py
  • pytest -q tests/unit/cli/test_query_exec_laws.py -k 'stats'
  • push hook: devtools verify --quick

@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 26 minutes and 8 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 26 minutes and 8 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e29f5a35-1eab-4633-b6e4-6608299bfbea

📥 Commits

Reviewing files that changed from the base of the PR and between bb62a7d and 6c0562d.

📒 Files selected for processing (1)
  • polylogue/cli/query_stats.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/query-stats-contracts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity force-pushed the feature/refactor/embed-status-contracts branch from 298b151 to fe19d91 Compare April 21, 2026 14:19
@Sinity
Sinity force-pushed the feature/refactor/query-stats-contracts branch from 01d4be0 to a1260f3 Compare April 21, 2026 14:21
Base automatically changed from feature/refactor/embed-status-contracts to master April 21, 2026 14:36
@Sinity
Sinity force-pushed the feature/refactor/query-stats-contracts branch from a1260f3 to 6c0562d Compare April 21, 2026 14:38
@Sinity
Sinity merged commit ff6a5b5 into master Apr 21, 2026
19 of 29 checks passed
@Sinity
Sinity deleted the feature/refactor/query-stats-contracts branch April 21, 2026 16:49
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- Adds shared grouped-stats table rendering for query stats surfaces.
- Reuses common date/provider grouping helpers across summary, conversation, semantic, and profile-backed stats.
- Preserves existing public function names and structured output payloads.

## Problem
`polylogue/cli/query_stats.py` repeated the same group sorting, Rich table construction, total-row rendering, and semantic grouping loops across several stats paths. That made the surface harder to review and easy to drift when changing output contracts.

## Solution
- Introduce typed internal helpers for grouped stats payloads, date/provider grouping keys, and table rendering.
- Route summary/date/provider stats, in-memory grouped conversation stats, semantic action/tool stats, and profile-backed stats through the shared renderer.
- Keep SQL archive stats and exported function names stable for existing call sites.

Ref #270

## Verification
- `ruff format polylogue/cli/query_stats.py`
- `ruff check polylogue/cli/query_stats.py`
- `mypy polylogue/cli/query_stats.py tests/unit/cli/test_query_exec_laws.py`
- `pytest -q tests/unit/cli/test_query_exec_laws.py -k 'stats'`
- push hook: `devtools verify --quick`
@Sinity Sinity added area:cli CLI area:parser Parser tool:claude Claude type:refactor Code restructuring labels Apr 22, 2026
Sinity added a commit that referenced this pull request Apr 22, 2026
`cli/query_stats.py` repeated the same group sorting, Rich table
construction, total-row rendering, and semantic grouping loops
across several stats paths. The surface was hard to review and
easy to drift when changing output contracts.

Introduces typed internal helpers for grouped stats payloads,
date/provider grouping keys, and table rendering. Routes summary/
date/provider stats, in-memory grouped conversation stats, semantic
action/tool stats, and profile-backed stats through the shared
renderer. Keeps SQL archive stats and exported function names
stable for existing call sites.

Verification: ruff + mypy + pytest over query-exec-laws stats
coverage; devtools verify --quick green.

Ref #270
Sinity added a commit that referenced this pull request Apr 22, 2026
`cli/query_stats.py` repeated the same group sorting, Rich table
construction, total-row rendering, and semantic grouping loops
across several stats paths. The surface was hard to review and
easy to drift when changing output contracts.

Introduces typed internal helpers for grouped stats payloads,
date/provider grouping keys, and table rendering. Routes summary/
date/provider stats, in-memory grouped conversation stats, semantic
action/tool stats, and profile-backed stats through the shared
renderer. Keeps SQL archive stats and exported function names
stable for existing call sites.

Verification: ruff + mypy + pytest over query-exec-laws stats
coverage; devtools verify --quick green.

Ref #270
Sinity added a commit that referenced this pull request Apr 22, 2026
`cli/query_stats.py` repeated the same group sorting, Rich table
construction, total-row rendering, and semantic grouping loops
across several stats paths. The surface was hard to review and
easy to drift when changing output contracts.

Introduces typed internal helpers for grouped stats payloads,
date/provider grouping keys, and table rendering. Routes summary/
date/provider stats, in-memory grouped conversation stats, semantic
action/tool stats, and profile-backed stats through the shared
renderer. Keeps SQL archive stats and exported function names
stable for existing call sites.

Verification: ruff + mypy + pytest over query-exec-laws stats
coverage; devtools verify --quick green.

Ref #270
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:53
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli CLI area:parser Parser tool:claude Claude type:refactor Code restructuring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant