-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat(explore): Adds starred queries backend models and endpoints #88448
feat(explore): Adds starred queries backend models and endpoints #88448
Conversation
This PR has a migration; here is the generated SQL for --
-- Create model ExploreSavedQueryStarred
--
CREATE TABLE "explore_exploresavedquerystarred" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "user_id" bigint NOT NULL, "position" smallint NOT NULL CHECK ("position" >= 0), "explore_saved_query_id" bigint NOT NULL, "organization_id" bigint NOT NULL, CONSTRAINT "explore_exploresavedquerystarred_unique_query_position_per_org_user" UNIQUE ("user_id", "organization_id", "position") DEFERRABLE INITIALLY DEFERRED);
ALTER TABLE "explore_exploresavedquerystarred" ADD CONSTRAINT "explore_exploresaved_explore_saved_query__55f1a783_fk_explore_e" FOREIGN KEY ("explore_saved_query_id") REFERENCES "explore_exploresavedquery" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "explore_exploresavedquerystarred" VALIDATE CONSTRAINT "explore_exploresaved_explore_saved_query__55f1a783_fk_explore_e";
ALTER TABLE "explore_exploresavedquerystarred" ADD CONSTRAINT "explore_exploresaved_organization_id_dbbddb21_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "explore_exploresavedquerystarred" VALIDATE CONSTRAINT "explore_exploresaved_organization_id_dbbddb21_fk_sentry_or";
CREATE INDEX CONCURRENTLY "explore_exploresavedquerystarred_user_id_243ad14e" ON "explore_exploresavedquerystarred" ("user_id");
CREATE INDEX CONCURRENTLY "explore_exploresavedquerys_explore_saved_query_id_55f1a783" ON "explore_exploresavedquerystarred" ("explore_saved_query_id");
CREATE INDEX CONCURRENTLY "explore_exploresavedquerystarred_organization_id_dbbddb21" ON "explore_exploresavedquerystarred" ("organization_id"); |
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #88448 +/- ##
===========================================
+ Coverage 56.24% 87.77% +31.53%
===========================================
Files 9918 9999 +81
Lines 563610 566943 +3333
Branches 22206 22206
===========================================
+ Hits 316976 497648 +180672
+ Misses 246232 68893 -177339
Partials 402 402 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelSun48 has been building something similar for saved issue searches. It might be worth you both collaborating a little here, because there are probably a lot of similarities. You might be able to share a lot of code, and just have different models passed through
Hey @wedamija , I discussed with @MichaelSun48 about this before working on this PR. There's definitely a lot of similarities. I'm actually just copying some of those existing models and adapting them for explore saved queries. If we want to share code, we'll probably need to run a migration to merge models/tables. The model manager can probably be updated to be generic easily without additional migrations. However, I'm avoiding making changes to the existing models for saved issue searches for the moment, because I know that feature is releasing soon and I don't want to introduce a new blocker (Explore Saved queries also has a short timeline). I plan to look into genericizing this code after both issue and explore features get released. Let me know if this is ok, or you have a strong opinion on this. |
src/sentry/explore/endpoints/explore_saved_query_starred_order.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm, I think it's pretty clear what these endpoints and API are intended to do/be used for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migration lgtm
) Adds a `ExploreSavedQueryStarred` model to support Starred Explore Queries in the new Sentry UI Side Nav. Includes a `ExploreSavedQueryStarredManager` to primarily handle validating and managing positioning of Starred items. Also adds new POST and PUT endpoints that utilizes this new model to star/unstar queries, and to rearrange list order. Updates the GET saved queries endpoint to also return starred status.
Adds a
ExploreSavedQueryStarred
model to support Starred Explore Queries in the new Sentry UI Side Nav.Includes a
ExploreSavedQueryStarredManager
to primarily handle validating and managing positioning of Starred items.Also adds new POST and PUT endpoints that utilizes this new model to star/unstar queries, and to rearrange list order. Updates the GET saved queries endpoint to also return starred status.
A large part of this code was adapted from the
GroupSearchViewStarred
model from the Issue Views product. There's an opportunity to make a genericStarred
model and manager, but I'd like to plan this for a future improvement to not add any new blockers to Issue Views or Explore timelines.