Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Sep 12, 2023
1 parent acee271 commit 222726f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions portal/views/cron/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ def get_unverified_users(days: int, same_day: bool) -> (int, int, QuerySet[User]
new_student__class_field__isnull=True,
)

return (
teacher_queryset.count(),
independent_student_queryset.count(),
teacher_queryset.union(independent_student_queryset),
)
return teacher_queryset, independent_student_queryset


def build_absolute_google_uri(request, location: str) -> str:
Expand All @@ -80,10 +76,11 @@ def build_absolute_google_uri(request, location: str) -> str:

class FirstVerifyEmailReminderView(CronMixin, APIView):
def get(self, request):
_, _, user_queryset = get_unverified_users(
teacher_queryset, independent_student_queryset = get_unverified_users(
USER_1ST_VERIFY_EMAIL_REMINDER_DAYS,
same_day=True,
)
user_queryset = teacher_queryset.union(independent_student_queryset)
user_count = user_queryset.count()

logging.info(f"{user_count} emails unverified.")
Expand Down Expand Up @@ -127,10 +124,11 @@ def get(self, request):

class SecondVerifyEmailReminderView(CronMixin, APIView):
def get(self, request):
_, _, user_queryset = get_unverified_users(
teacher_queryset, independent_student_queryset = get_unverified_users(
USER_2ND_VERIFY_EMAIL_REMINDER_DAYS,
same_day=True,
)
user_queryset = teacher_queryset.union(independent_student_queryset)
user_count = user_queryset.count()

logging.info(f"{user_count} emails unverified.")
Expand Down Expand Up @@ -176,10 +174,14 @@ class DeleteUnverifiedAccounts(CronMixin, APIView):
def get(self, request):
user_count = User.objects.count()

teacher_count, indy_count, user_queryset = get_unverified_users(
teacher_queryset, independent_student_queryset = get_unverified_users(
USER_DELETE_UNVERIFIED_ACCOUNT_DAYS,
same_day=False,
)
teacher_count = teacher_queryset.count()
indy_count = independent_student_queryset.count()

user_queryset = teacher_queryset.union(independent_student_queryset)

for user in user_queryset.iterator(chunk_size=100):
try:
Expand Down

0 comments on commit 222726f

Please sign in to comment.