Skip to content
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

migrations(shared-views): Create groupsearchviewlastvisited table #86241

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

MichaelSun48
Copy link
Member

@MichaelSun48 MichaelSun48 commented Mar 3, 2025

This PR creates a new table, groupsearchviewlastvisited. More details on why we are doing this can be found in this tech spec (internal only).

TL;DR — We need a table to keep track of when the last time a user looks at view.

@MichaelSun48 MichaelSun48 requested a review from a team March 3, 2025 22:33
@MichaelSun48 MichaelSun48 requested a review from a team as a code owner March 3, 2025 22:33
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 3, 2025
Copy link
Contributor

github-actions bot commented Mar 3, 2025

This PR has a migration; here is the generated SQL for src/sentry/migrations/0837_create_groupsearchviewlastseen_table.py ()

--
-- Create model GroupSearchViewLastVisited
--
CREATE TABLE "sentry_groupsearchviewlastvisited" ("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, "last_visited" timestamp with time zone NOT NULL, "group_search_view_id" bigint NOT NULL, "organization_id" bigint NOT NULL, CONSTRAINT "sentry_groupsearchviewlastvisited_unique_last_visited_per_org_user_view" UNIQUE ("user_id", "organization_id", "group_search_view_id"));
ALTER TABLE "sentry_groupsearchviewlastvisited" ADD CONSTRAINT "sentry_groupsearchvi_group_search_view_id_ba7312f8_fk_sentry_gr" FOREIGN KEY ("group_search_view_id") REFERENCES "sentry_groupsearchview" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_groupsearchviewlastvisited" VALIDATE CONSTRAINT "sentry_groupsearchvi_group_search_view_id_ba7312f8_fk_sentry_gr";
ALTER TABLE "sentry_groupsearchviewlastvisited" ADD CONSTRAINT "sentry_groupsearchvi_organization_id_0c751d81_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_groupsearchviewlastvisited" VALIDATE CONSTRAINT "sentry_groupsearchvi_organization_id_0c751d81_fk_sentry_or";
CREATE INDEX CONCURRENTLY "sentry_groupsearchviewlastvisited_user_id_b4c3778c" ON "sentry_groupsearchviewlastvisited" ("user_id");
CREATE INDEX CONCURRENTLY "sentry_groupsearchviewlastvisited_group_search_view_id_ba7312f8" ON "sentry_groupsearchviewlastvisited" ("group_search_view_id");
CREATE INDEX CONCURRENTLY "sentry_groupsearchviewlastvisited_organization_id_0c751d81" ON "sentry_groupsearchviewlastvisited" ("organization_id");

Copy link
Member

@wedamija wedamija left a comment

Choose a reason for hiding this comment

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

Migration lgtm

@MichaelSun48 MichaelSun48 changed the title migrations(shared-views): Create groupsearchviewlastseen table migrations(shared-views): Create groupsearchviewlastvisited table Mar 3, 2025
@MichaelSun48
Copy link
Member Author

MichaelSun48 commented Mar 3, 2025

renamed everything to last_visited (instead of last_seen) since this aligns with prior art (saved explore and discover queries)

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #86241       +/-   ##
===========================================
+ Coverage   56.38%   87.88%   +31.50%     
===========================================
  Files        9714     9722        +8     
  Lines      550669   551067      +398     
  Branches    21478    21478               
===========================================
+ Hits       310510   484322   +173812     
+ Misses     239806    66392   -173414     
  Partials      353      353               

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants