Skip to content

fix: list new queries in the PR comment, not just count them#151

Merged
veksen merged 2 commits into
mainfrom
fix-pr-comment-list-new-queries
Jun 16, 2026
Merged

fix: list new queries in the PR comment, not just count them#151
veksen merged 2 commits into
mainfrom
fix-pr-comment-list-new-queries

Conversation

@veksen

@veksen veksen commented Jun 16, 2026

Copy link
Copy Markdown
Member

Follow-up to the run-page / baseline work (Query-Doctor/Site bug report; epic Query-Doctor/Site#3106).

Problem

The PR comment header shows e.g. "74 queries analyzed | 1 new query" and the roll-up says "1 new", but the body never lists which query is new. A new query only appeared in the comment if it carried an index recommendation (under "This PR introduces queries with recommendations"). A new query with no recommendation — e.g. an index-covered query that's new but not a problem — was counted in the tally and listed nowhere, making "1 new" unactionable from the PR.

Fix (analyzer-only)

compareRuns already produces newQueries with full SQL — the data was there, just never rendered. buildViewModel now also returns displayNewQueries: the new queries whose hash carries no index recommendation (the ones that do have a recommendation already render under the recommendations section, so they're excluded here to avoid double-listing). The template gains a "This PR introduces new queries" section listing each one's SQL preview, cost, and run link (cost N · no index suggestion).

No API change needed: the analyzer already computes the comparison locally whenever it can fetch a baseline. (When no baseline is available there's nothing to attribute — the existing no-baseline / temporarily-unavailable messaging covers that.)

Tests

  • buildViewModel: a new query without a recommendation is listed in displayNewQueries; a new query with a recommendation is not double-listed.
  • Template: renders the "This PR introduces new queries" section with the query's SQL and cost N · no index suggestion.
  • 54/54 affected unit tests pass; tsc --noEmit clean. Two golden-file snapshots gained a single blank line — the same empty-section gap every other optional section already emits (GitHub collapses it); verified the snapshot delta is whitespace-only.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Query Doctor Analysis

3 queries analyzed

0 regressed · 0 improved · 0 new · 0 removed

2 pre-existing issues

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

More detail → get_ci_run({ runId: "019ed20f-b573-7262-b2aa-3b74da5f9085" }) · view run · docs

veksen and others added 2 commits June 16, 2026 16:10
A new query with no index recommendation was counted in the "N new" tally but
listed nowhere in the comment body, so "1 new query" was unactionable from the
PR — the reported index-covered query was new but invisible (Query-Doctor/Site
bug report). compareRuns already yields the new queries with their SQL; surface
the ones that carry no recommendation (those with a recommendation already
render under "introduces queries with recommendations") in a new
"This PR introduces new queries" section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The header said "N queries analyzed | N new query" while the roll-up line right
below already states "· N new ·", so the new count appeared twice on adjacent
lines. With new queries now listed in their own section, the header callout is
pure redundancy — drop it and let the roll-up carry the tally. Also lets the
header sit a blank line clear of the roll-up instead of jammed against it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@veksen veksen force-pushed the fix-pr-comment-list-new-queries branch from 2793c2e to a9f81a5 Compare June 16, 2026 20:10
@veksen veksen merged commit a2970c1 into main Jun 16, 2026
6 checks passed
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