Skip to content

Commit

Permalink
Simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Aug 31, 2023
1 parent 3d46d16 commit 5b5acfd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions portal/views/cron/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ def get(self, request):
new_user__date_joined__lte=timezone.now() - timedelta(days=USER_DELETE_UNVERIFIED_ACCOUNT_DAYS),
).values_list("new_user__email", flat=True)

unverified_emails = list(chain(unverified_teachers, unverified_students))
unverified_emails_count = len(unverified_emails)
unverified_teachers_count = unverified_teachers.count()
unverified_students_count = unverified_students.count()

User.objects.filter(email__in=unverified_emails).delete()
unverified_teachers.delete()
unverified_students.delete()

logging.info(f"{unverified_emails_count} unverified users deleted.")
logging.info(f"{unverified_teachers_count + unverified_students_count} unverified users deleted.")

return Response()

0 comments on commit 5b5acfd

Please sign in to comment.