Remove cargo culted .all()
This commit is contained in:
parent
783ab54b61
commit
264dc30639
1 changed files with 6 additions and 6 deletions
|
@ -7,10 +7,10 @@ from users.models import CustomUser
|
|||
|
||||
|
||||
def calc_score(user: CustomUser):
|
||||
registrations_last_month = EventRegistration.objects.all().filter(user_id=user.id,
|
||||
event__date__gt=date.today() - timedelta(days=30),
|
||||
event__date__lte=date.today(),
|
||||
state=EventRegistration.ADMITTED)
|
||||
registrations_last_month = EventRegistration.objects.filter(user_id=user.id,
|
||||
event__date__gt=date.today() - timedelta(days=30),
|
||||
event__date__lte=date.today(),
|
||||
state=EventRegistration.ADMITTED)
|
||||
score = 0
|
||||
for r in registrations_last_month:
|
||||
days_ago = (date.today() - r.event.date.date()).days
|
||||
|
@ -30,10 +30,10 @@ def assign_reservations(self):
|
|||
print("Assigning reservations")
|
||||
print("======================")
|
||||
# Get all events of tomorrow
|
||||
events = Event.objects.all().filter(date__date=date.today() + timedelta(days=1))
|
||||
events = Event.objects.filter(date__date=date.today() + timedelta(days=1))
|
||||
|
||||
# Reservations
|
||||
registrations: List[EventRegistration] = EventRegistration.objects.all().filter(
|
||||
registrations: List[EventRegistration] = EventRegistration.objects.filter(
|
||||
event_id__in=map(lambda event: event.id, events),
|
||||
state=EventRegistration.INTERESTED)
|
||||
if len(registrations) == 0:
|
||||
|
|
Loading…
Reference in a new issue