Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from DemocracyClub/unique-emails
Browse files Browse the repository at this point in the history
Lower case emails to filter on unique
  • Loading branch information
VirginiaDooley authored May 23, 2023
2 parents ff01773 + 4deeee0 commit 8a38108
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import time
from django.core.management.base import BaseCommand
from django.db.models import Q
from django.db.models import Q, Func, F
from dc_signup_form.signup_server.models import SignupQueue
from dc_signup_form.signup_server.wrappers import DCSendGridWrapper

Expand All @@ -16,15 +16,18 @@ def get_unique_mailing_lists(self):
)

def get_new_users(self, mailing_lists):
return SignupQueue.objects.all().filter(
~Q(email="[email protected]"),
added=False,
mailing_lists=mailing_lists,
).distinct("email")

return (
SignupQueue.objects.all()
.filter(
~Q(email="[email protected]"),
added=False,
mailing_lists=mailing_lists,
)
.annotate(email_lower=Func(F("email"), function="lower"))
.distinct("email_lower")
)

def handle(self, *args, **kwargs):

# Assume we're going to finish sucessfully.
# If any errors happen, we'll set an error code
exit_code = 0
Expand Down

0 comments on commit 8a38108

Please sign in to comment.