Skip to content

feat(dashboards): Add model for storing visit information #95361

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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

narsaynorath
Copy link
Member

Adds a model that will be created for a singular visit by a user to a particular dashboard. This is to move us away from a generic global "last visited" timestamp on dashboards and something more focused on the user themselves.

Closes DAIN-731

Adds a model that will be created for a singular visit by a user to a
particular dashboard. This is to move us away from a generic global
"last visited" timestamp on dashboards and something more focused on the
user themselves.
@narsaynorath narsaynorath requested a review from a team as a code owner July 11, 2025 18:31
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 11, 2025
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0947_add_dashboard_last_visited_model.py

for 0947_add_dashboard_last_visited_model in sentry

--
-- Create model DashboardLastVisited
--
CREATE TABLE "sentry_dashboardlastvisited" ("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, "last_visited" timestamp with time zone NOT NULL, "dashboard_id" bigint NOT NULL, "member_id" bigint NOT NULL, CONSTRAINT "sentry_dashboardlastvisited_unique_last_visited_per_org_member_view" UNIQUE ("member_id", "dashboard_id"));
ALTER TABLE "sentry_dashboardlastvisited" ADD CONSTRAINT "sentry_dashboardlast_dashboard_id_31d3a51b_fk_sentry_da" FOREIGN KEY ("dashboard_id") REFERENCES "sentry_dashboard" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_dashboardlastvisited" VALIDATE CONSTRAINT "sentry_dashboardlast_dashboard_id_31d3a51b_fk_sentry_da";
ALTER TABLE "sentry_dashboardlastvisited" ADD CONSTRAINT "sentry_dashboardlast_member_id_28801a0a_fk_sentry_or" FOREIGN KEY ("member_id") REFERENCES "sentry_organizationmember" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_dashboardlastvisited" VALIDATE CONSTRAINT "sentry_dashboardlast_member_id_28801a0a_fk_sentry_or";
CREATE INDEX CONCURRENTLY "sentry_dashboardlastvisited_dashboard_id_31d3a51b" ON "sentry_dashboardlastvisited" ("dashboard_id");
CREATE INDEX CONCURRENTLY "sentry_dashboardlastvisited_member_id_28801a0a" ON "sentry_dashboardlastvisited" ("member_id");

cursor[bot]

This comment was marked as outdated.

Copy link

codecov bot commented Jul 11, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
27215 2 27213 242
View the top 2 failed test(s) by shortest run time
tests.sentry.backup.test_exhaustive.ExhaustiveTests::test_exhaustive_dirty_pks
Stack Traces | 45s run time
#x1B[1m#x1B[.../sentry/backup/test_exhaustive.py#x1B[0m:38: in test_exhaustive_dirty_pks
    actual = self.import_export_then_validate(self._testMethodName, reset_pks=False)
#x1B[1m#x1B[.../testutils/helpers/backups.py#x1B[0m:907: in import_export_then_validate
    return import_export_then_validate(out_name, reset_pks=reset_pks)
#x1B[1m#x1B[.../testutils/helpers/backups.py#x1B[0m:338: in import_export_then_validate
    raise ValidationError(res)
#x1B[1m#x1B[31mE   sentry.testutils.helpers.backups.ValidationError: ComparatorFinding(#x1B[0m
#x1B[1m#x1B[31mE       kind: UnequalJSON,#x1B[0m
#x1B[1m#x1B[31mE       on: InstanceID(model: 'sentry.dashboardlastvisited', ordinal: 1),#x1B[0m
#x1B[1m#x1B[31mE       left_pk: 2,#x1B[0m
#x1B[1m#x1B[31mE       right_pk: 1,#x1B[0m
#x1B[1m#x1B[31mE       reason: #x1B[0m
#x1B[1m#x1B[31mE       --- #x1B[0m
#x1B[1m#x1B[31mE   #x1B[0m
#x1B[1m#x1B[31mE       +++ #x1B[0m
#x1B[1m#x1B[31mE   #x1B[0m
#x1B[1m#x1B[31mE       @@ -1,5 +1,5 @@#x1B[0m
#x1B[1m#x1B[31mE   #x1B[0m
#x1B[1m#x1B[31mE        {#x1B[0m
#x1B[1m#x1B[31mE       -  "date_added": "2025-07-11T19:00:12.893Z",#x1B[0m
#x1B[1m#x1B[31mE       -  "date_updated": "2025-07-11T19:00:12.893Z",#x1B[0m
#x1B[1m#x1B[31mE       +  "date_added": "2025-07-11T19:00:16.038Z",#x1B[0m
#x1B[1m#x1B[31mE       +  "date_updated": "2025-07-11T19:00:16.038Z",#x1B[0m
#x1B[1m#x1B[31mE          "last_visited": "2025-07-11T19:00:12.892Z"#x1B[0m
#x1B[1m#x1B[31mE        }#x1B[0m
#x1B[1m#x1B[31mE   )#x1B[0m
tests.sentry.backup.test_exhaustive.ExhaustiveTests::test_exhaustive_dirty_pks
Stack Traces | 51.4s run time
#x1B[1m#x1B[.../sentry/backup/test_exhaustive.py#x1B[0m:38: in test_exhaustive_dirty_pks
    actual = self.import_export_then_validate(self._testMethodName, reset_pks=False)
#x1B[1m#x1B[.../testutils/helpers/backups.py#x1B[0m:907: in import_export_then_validate
    return import_export_then_validate(out_name, reset_pks=reset_pks)
#x1B[1m#x1B[.../testutils/helpers/backups.py#x1B[0m:338: in import_export_then_validate
    raise ValidationError(res)
#x1B[1m#x1B[31mE   sentry.testutils.helpers.backups.ValidationError: ComparatorFinding(#x1B[0m
#x1B[1m#x1B[31mE       kind: UnequalJSON,#x1B[0m
#x1B[1m#x1B[31mE       on: InstanceID(model: 'sentry.dashboardlastvisited', ordinal: 1),#x1B[0m
#x1B[1m#x1B[31mE       left_pk: 11,#x1B[0m
#x1B[1m#x1B[31mE       right_pk: 12,#x1B[0m
#x1B[1m#x1B[31mE       reason: #x1B[0m
#x1B[1m#x1B[31mE       --- #x1B[0m
#x1B[1m#x1B[31mE   #x1B[0m
#x1B[1m#x1B[31mE       +++ #x1B[0m
#x1B[1m#x1B[31mE   #x1B[0m
#x1B[1m#x1B[31mE       @@ -1,5 +1,5 @@#x1B[0m
#x1B[1m#x1B[31mE   #x1B[0m
#x1B[1m#x1B[31mE        {#x1B[0m
#x1B[1m#x1B[31mE       -  "date_added": "2025-07-11T19:11:52.758Z",#x1B[0m
#x1B[1m#x1B[31mE       -  "date_updated": "2025-07-11T19:11:52.758Z",#x1B[0m
#x1B[1m#x1B[31mE       +  "date_added": "2025-07-11T19:11:56.707Z",#x1B[0m
#x1B[1m#x1B[31mE       +  "date_updated": "2025-07-11T19:11:56.707Z",#x1B[0m
#x1B[1m#x1B[31mE          "last_visited": "2025-07-11T19:11:52.757Z"#x1B[0m
#x1B[1m#x1B[31mE        }#x1B[0m
#x1B[1m#x1B[31mE   )#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Schema changes look good to me.

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.

2 participants