ROX-33254: use SQL aggregate query for GetAlertsGroup#19166
Draft
dashrews78 wants to merge 1 commit intodashrews/resolvers-alert-policy-counts-33251from
Draft
ROX-33254: use SQL aggregate query for GetAlertsGroup#19166dashrews78 wants to merge 1 commit intodashrews/resolvers-alert-policy-counts-33251from
dashrews78 wants to merge 1 commit intodashrews/resolvers-alert-policy-counts-33251from
Conversation
Replace the unbounded SearchListAlerts call (which deserializes every alert protobuf blob and groups in-memory) with a SQL GROUP BY + COUNT query that computes per-policy alert counts entirely in the database. The new SearchAlertPolicyGroups datastore method follows the established pattern from SearchAlertPolicySeverityCounts: a view struct with db tags, a query builder that adds SELECT/GROUP BY/ORDER BY clauses, and RunSelectRequestForSchemaFn for execution. Categories are omitted from the response since the Dashboard UI consumer (the only caller) does not use them from this endpoint. AI-assisted development. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
This change is part of the following stack: Change managed by git-spice. |
|
Skipping CI for Draft Pull Request. |
Contributor
|
Images are ready for the commit at aaedb9d. To use with deploy scripts, first |
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.
Description
Replace the unbounded SearchListAlerts call (which deserializes every alert protobuf blob and groups in-memory) with a SQL GROUP BY + COUNT query that computes per-policy alert counts entirely in the database.
The new SearchAlertPolicyGroups datastore method follows the established pattern from SearchAlertPolicySeverityCounts: a view struct with db tags, a query builder that adds SELECT/GROUP BY/ORDER BY clauses, and RunSelectRequestForSchemaFn for execution.
AI-assisted development.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
User-facing documentation
Testing and quality
Automated testing
How I validated my change
change me!