-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(explore): Adds prebuilt queries to Explore #90720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edwardgou-sentry
wants to merge
3
commits into
master
Choose a base branch
from
egou/feat/explore-prebuilt-queries
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
e978b34
to
6b1123c
Compare
This PR has a migration; here is the generated SQL for for --
-- Add field prebuilt_id to exploresavedquery
--
ALTER TABLE "explore_exploresavedquery" ADD COLUMN "prebuilt_id" integer DEFAULT NULL NULL CHECK ("prebuilt_id" >= 0);
--
-- Add field prebuilt_version to exploresavedquery
--
ALTER TABLE "explore_exploresavedquery" ADD COLUMN "prebuilt_version" integer DEFAULT NULL NULL CHECK ("prebuilt_version" >= 0);
--
-- Add field starred to exploresavedquerystarred
--
ALTER TABLE "explore_exploresavedquerystarred" ADD COLUMN "starred" boolean DEFAULT true NOT NULL;
--
-- Alter field position on exploresavedquerystarred
--
ALTER TABLE "explore_exploresavedquerystarred" ALTER COLUMN "position" SET DEFAULT NULL;
ALTER TABLE "explore_exploresavedquerystarred" ALTER COLUMN "position" DROP NOT NULL;
--
-- Alter unique_together for exploresavedquery (1 constraint(s))
--
CREATE UNIQUE INDEX CONCURRENTLY "explore_exploresavedquer_organization_id_prebuilt_26175712_uniq" ON "explore_exploresavedquery" ("organization_id", "prebuilt_id");
ALTER TABLE "explore_exploresavedquery" ADD CONSTRAINT "explore_exploresavedquer_organization_id_prebuilt_26175712_uniq" UNIQUE USING INDEX "explore_exploresavedquer_organization_id_prebuilt_26175712_uniq"; |
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #90720 +/- ##
==========================================
- Coverage 87.78% 87.78% -0.01%
==========================================
Files 10274 10275 +1
Lines 582608 582701 +93
Branches 22567 22567
==========================================
+ Hits 511423 511498 +75
- Misses 70756 70774 +18
Partials 429 429 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Scope: Backend
Automatically applied to PRs that change backend components
Scope: Frontend
Automatically applied to PRs that change frontend components
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.
Adds prebuilt queries to Explore:
PREBUILT_SAVED_QUERIES
are saved as hardcoded dicts inexplore_saved_queries.py
.On the first time
GET
is called onExploreSavedQueriesEndpoint
, we insertPREBUILT_SAVED_QUERIES
entries into the saved queries db table, if they do not already exist. We also update or delete saved prebuilt queries in the db if there are changes detected (seesync_prebuilt_queries
).If it's the first time a user is fetching prebuilt queries, we also "star" them for the user by default. See
sync_prebuilt_queries_starred
.This allows users to (mostly) interact with prebuilt queries in the same way as user generated saved queries (ie star, reorder star position, search filter, search sort, duplicate, etc). This also allows Sentry to add, change, or delete any prebuilt queries in the future. We do not allow users to delete or edit prebuilt queries.
The following migration changes are needed to support prebuilt queries:
prebuilt_id
column to theExploreSavedQuery
model. This is so we know a saved query is prebuilt, and also serves as an identifier for when we need to rename or change a prebuilt query for the customer.prebuilt_version
column to theExploreSavedQuery
model. Serves as a way to version control saved prebuilt queries. ie, ifprebuilt_version
in the hardcodedPREBUILT_SAVED_QUERIES
is greater thanprebuilt_version
in the db, we must update the db entry.starred
column to theExploreSavedQueryStarred
model, and makeposition
nullable. This is necessary to support "starring" prebuilt queries by default. In the past, when a saved query is 'unstarred', we delete the entry fromExploreSavedQueryStarred
to reflect this state. However, with prebuilt queries, when there is no entry in theExploreSavedQueryStarred
model, we can't tell if this means the prebuilt query was 'unstarred' by the user or if it's the first time the user is reading the prebuilt query. By adding astarred
column, we can distinguish between these two different states.