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

✨ Set donor subscriber to null when newsletter unsubscribe #433

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

pajowu
Copy link
Member

@pajowu pajowu commented Nov 7, 2023

No description provided.

@pajowu pajowu requested review from krmax44 and stefanw November 7, 2023 14:05
@pajowu
Copy link
Member Author

pajowu commented Nov 7, 2023

Suggested code to run to cleanup old donors:

from django.utils import timezone
from datetime import timedelta
from fragdenstaat_de.fds_donation.models import Donor

now = timezone.now()
three_days_ago = now - timedelta(days=3)
donors = Donor.objects.filter(subscriber__unsubscribed__lt=three_days_ago)
donors.update(subscriber=None)

@stefanw
Copy link
Member

stefanw commented Nov 7, 2023

Ideally, I'd try to move this into fds_donation, so fds_newsletter doesn't need to know about donations (the fds_newsletter/analytics.py was a mistake in that regard and we already have a different solution in place). Maybe using the unsubscribed signal of the newsletter system in fds_donation/apps.py. Then it also immediately disconnects instead of during the cleanup cycle.

@pajowu pajowu force-pushed the pajowu/set_subscriber_null branch from 4622e27 to 31296dd Compare November 7, 2023 16:08
@pajowu
Copy link
Member Author

pajowu commented Nov 7, 2023

Sure, how about this solution?

@stefanw stefanw force-pushed the pajowu/set_subscriber_null branch from 31296dd to 710a85c Compare November 9, 2023 12:30
@pajowu pajowu enabled auto-merge (rebase) November 9, 2023 12:35
@pajowu pajowu merged commit faedc97 into main Nov 9, 2023
3 checks passed
@pajowu pajowu deleted the pajowu/set_subscriber_null branch November 9, 2023 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants