Skip to content

chore: Add 'last_seen' and 'times_seen' columns to table grouptombstone #93682

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 21 commits into
base: master
Choose a base branch
from

Conversation

priscilawebdev
Copy link
Member

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 17, 2025
Copy link

codecov bot commented Jun 17, 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   #93682       +/-   ##
===========================================
+ Coverage   76.56%   88.03%   +11.46%     
===========================================
  Files       10338    10341        +3     
  Lines      597261   597010      -251     
  Branches    23193    23138       -55     
===========================================
+ Hits       457316   525599    +68283     
+ Misses     139484    70955    -68529     
+ Partials      461      456        -5     

@priscilawebdev priscilawebdev changed the base branch from master to priscila/chore/add-grouptomstones-hit-counter-feature-flag June 17, 2025 09:18
…lag' into priscila/chore/add-hit-tracker-columns-to-grouptombstone
Copy link
Member

@vgrozdanic vgrozdanic left a comment

Choose a reason for hiding this comment

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

Blocking the merge since this can cause some problems

…lag' into priscila/chore/add-hit-tracker-columns-to-grouptombstone
Base automatically changed from priscila/chore/add-grouptomstones-hit-counter-feature-flag to master June 17, 2025 16:11
@getsentry getsentry deleted a comment from github-actions bot Jun 18, 2025
Copy link
Contributor

github-actions bot commented Jun 18, 2025

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

for 0930_add_hit_counter_columns_to_grouptombstone in sentry

--
-- Add field last_seen to grouptombstone
--
ALTER TABLE "sentry_grouptombstone" ADD COLUMN "last_seen" timestamp with time zone NULL;
--
-- Add field times_seen to grouptombstone
--
ALTER TABLE "sentry_grouptombstone" ADD COLUMN "times_seen" integer DEFAULT 0 NOT NULL CHECK ("times_seen" >= 0);

@@ -39,6 +39,8 @@ class GroupTombstone(Model):
blank=True, null=True
)
actor_id = BoundedPositiveIntegerField(null=True)
times_seen = BoundedPositiveIntegerField(db_default=0)
last_seen = models.DateTimeField(default=None, null=True)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: for last_seen, If you just want the default to be None, you don't need to include this default at all.

If you want it to just be set to the current date/time when the row is first created, you can use auto_now_add=True instead of using a default.

Copy link
Member Author

@priscilawebdev priscilawebdev Jun 18, 2025

Choose a reason for hiding this comment

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

I was planning to write another migration just to do that for new future records (rows), and you just saved me from that! thank youuu

Copy link
Member Author

Choose a reason for hiding this comment

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

ok unfortunately this does not work the way I expected. I would like existing rows to be null and future rows to have a timestamp. There is no another way but creating 2 migrations for that

Copy link
Contributor

github-actions bot commented Jun 18, 2025

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

for 0931_add_hit_counter_columns_to_grouptombstone in sentry

--
-- Add field last_seen to grouptombstone
--
ALTER TABLE "sentry_grouptombstone" ADD COLUMN "last_seen" timestamp with time zone NULL;
--
-- Add field times_seen to grouptombstone
--
ALTER TABLE "sentry_grouptombstone" ADD COLUMN "times_seen" integer DEFAULT 0 NOT NULL CHECK ("times_seen" >= 0);

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.

5 participants