Skip to content

fix: use deduplicated query count in PR comment#94

Open
veksen wants to merge 1 commit intomainfrom
veksen/fix-pr-query-count
Open

fix: use deduplicated query count in PR comment#94
veksen wants to merge 1 commit intomainfrom
veksen/fix-pr-query-count

Conversation

@veksen
Copy link
Copy Markdown
Member

@veksen veksen commented Mar 23, 2026

Summary

The PR comment showed the raw pgbadger log entry count (queryStats.total) instead of the deduplicated/filtered query count, causing a mismatch — e.g. "28 queries analyzed" while the app showed "Queries (5)".

Root cause: queryStats.total++ was at the top of processQuery(), counting every log entry — including ignored, introspection, duplicate, and catalog queries that get filtered out.

Fix: Move queryStats.total++ to after all early-return filters so it only counts queries that actually get analyzed. No post-hoc patching needed.

Test plan

  • Template renders queryStats.total as the query count (with and without comparison)
  • buildQueries correctly filters invalid results and ignored hashes
  • All 32 tests pass

🤖 Generated with Claude Code

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query Doctor Analysis

View full run details

10 queries analyzed

2 pre-existing issues

Using assumed statistics (10000 rows/table). For better results, sync production stats.

@veksen veksen force-pushed the veksen/fix-pr-query-count branch from 77bc309 to b999002 Compare March 27, 2026 15:41
Move queryStats.total++ past all early-return filters (ignored,
introspection, duplicate, catalog) so it reflects the actual number
of unique queries analyzed — not the raw log entry count.

This fixes the mismatch between the PR comment ("X queries analyzed")
and the app's query list without needing a post-hoc patch in main.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@veksen veksen force-pushed the veksen/fix-pr-query-count branch from b999002 to 511b699 Compare March 28, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant