-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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(backup): Generate cloned QuerySubscription on import #56023
Conversation
dc76ccf
to
435bdf3
Compare
80b5447
to
183f191
Compare
435bdf3
to
4577593
Compare
183f191
to
c92fc3c
Compare
4577593
to
dfb047a
Compare
c92fc3c
to
010e70e
Compare
Codecov Report
@@ Coverage Diff @@
## master #56023 +/- ##
===========================================
+ Coverage 66.67% 79.99% +13.32%
===========================================
Files 5063 5066 +3
Lines 217573 218017 +444
Branches 36828 36898 +70
===========================================
+ Hits 145061 174398 +29337
+ Misses 66929 38270 -28659
+ Partials 5583 5349 -234
|
src/sentry/snuba/models.py
Outdated
|
||
# Keep the original dates. | ||
subscription.date_added = self.date_added | ||
subscription.date_updated = self.date_updated |
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.
Does it make sense to have a new date_updated
here instead of using the old value?
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.
You're right - I've removed this line.
if old_pk is None: | ||
return None | ||
|
||
subscription = create_snuba_subscription(self.project, self.type, self.snuba_query) |
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.
Previously, were imports for this working at all? Wondering if there was some setup missing that create_snuba_subscription
does
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.
I don't see how they would have worked. This is one of the (many) ways that old import/export was broken.
To avoid creating duplicate `subscription_id`s, rather than naively copying in imported model data, we instead take this data to construct a new call to `create_snuba_subscription`. This will generate an identical subscription (modulo creation/edit dates, which we overwrite), but with a new `subscription_id`. Closes getsentry/team-ospo#193
010e70e
to
c4e56c6
Compare
To avoid creating duplicate
subscription_id
s, rather than naively copying in imported model data, we instead take this data to construct a new call tocreate_snuba_subscription
. This will generate an identical subscription (modulo creation/edit dates, which we overwrite), but with a newsubscription_id
.Closes getsentry/team-ospo#193