[WEI] Fix quotas

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-09-16 23:48:03 +02:00
parent 8638c16b34
commit 161db0b00b
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 6 additions and 0 deletions

View File

@ -207,6 +207,9 @@ class WEISurveyAlgorithm2021(WEISurveyAlgorithm):
non_men_total = registrations.filter(~Q(gender='male')).count() non_men_total = registrations.filter(~Q(gender='male')).count()
for bus in self.get_buses(): for bus in self.get_buses():
free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count() free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count()
# Remove hardcoded people
free_seats -= WEIMembership.objects.filter(bus=bus, registration__first_year=True,
registration__information_json__icontains="hardcoded").count()
quotas[bus] = 4 + int(non_men_total / registrations.count() * free_seats) quotas[bus] = 4 + int(non_men_total / registrations.count() * free_seats)
tqdm_obj = None tqdm_obj = None
@ -221,6 +224,9 @@ class WEISurveyAlgorithm2021(WEISurveyAlgorithm):
for bus in self.get_buses(): for bus in self.get_buses():
free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count() free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count()
free_seats -= sum(1 for s in non_men if s.information.selected_bus_pk == bus.pk) free_seats -= sum(1 for s in non_men if s.information.selected_bus_pk == bus.pk)
# Remove hardcoded people
free_seats -= WEIMembership.objects.filter(bus=bus, registration__first_year=True,
registration__information_json__icontains="hardcoded").count()
quotas[bus] = free_seats quotas[bus] = free_seats
if display_tqdm: if display_tqdm: