fix: list new queries in the PR comment, not just count them#151
Merged
Conversation
There was a problem hiding this comment.
Query Doctor Analysis
3 queries analyzed
0 regressed · 0 improved · 0 new · 0 removed
2 pre-existing issues
SELECT "guests"."id", "guests"."session_id", "guests"."username", "guests"."avatar_path", "guests"."color", "guests"."side", "guests"."audio_recording_path", "guests"."audio_recording_public", "gue...
indexassets(event_id, inserted_at desc)
cost 31,003,449 → 1,498 (100% reduction)SELECT * FROM guest_ip_addresses WHERE ip_address = '127.0.0.1';
indexguest_ip_addresses(ip_address)
cost 154,402 → 8 (100% reduction)
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
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>
2793c2e to
a9f81a5
Compare
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.
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)
compareRunsalready producesnewQuerieswith full SQL — the data was there, just never rendered.buildViewModelnow also returnsdisplayNewQueries: 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 indisplayNewQueries; a new query with a recommendation is not double-listed.cost N · no index suggestion.tsc --noEmitclean. 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.