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

fix: Fix subscriptions sending twice #21581

Merged
merged 14 commits into from
Apr 18, 2024
2 changes: 1 addition & 1 deletion ee/tasks/subscriptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _deliver_subscription_report(
raise NotImplementedError(f"{subscription.target_type} is not supported")

if not is_new_subscription_target:
subscription.set_next_delivery_date()
subscription.set_next_delivery_date(subscription.next_delivery_date)
subscription.save()


Expand Down
2 changes: 2 additions & 0 deletions posthog/models/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def save(self, *args, **kwargs) -> None:
# Only if the schedule has changed do we update the next delivery date
if not self.id or str(self._rrule) != str(self.rrule):
self.set_next_delivery_date()
if "update_fields" in kwargs:
kwargs["update_fields"].append("next_delivery_date")
Comment on lines +135 to +136
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now recommended to add in Django 4.2, so doing it here while on it.

https://docs.djangoproject.com/en/4.2/releases/4.2/#setting-update-fields-in-model-save-may-now-be-required

super(Subscription, self).save(*args, **kwargs)

@property
Expand Down
Loading