|
6 | 6 | from django.utils import timezone |
7 | 7 |
|
8 | 8 | from app.views import TabsView |
| 9 | +from applications import models as a_models |
9 | 10 | from applications.models import Application, STATUS, APP_CONFIRMED, GENDERS |
10 | 11 | from user.mixins import is_organizer, IsOrganizerMixin |
11 | 12 |
|
@@ -57,11 +58,17 @@ def app_stats_api(request): |
57 | 58 | gender_count = Application.objects.all().values('gender') \ |
58 | 59 | .annotate(applications=Count('gender')) |
59 | 60 | gender_count = map(lambda x: dict(gender_name=GENDER_DICT[x['gender']], **x), gender_count) |
| 61 | + tshirt_dict = dict(a_models.TSHIRT_SIZES) |
| 62 | + shirt_count = map( |
| 63 | + lambda x: {'tshirt_size': tshirt_dict.get(x['tshirt_size'], 'Unknown'), 'applications': x['applications']}, |
| 64 | + Application.objects.values('tshirt_size').annotate(applications=Count('tshirt_size')) |
| 65 | + ) |
60 | 66 |
|
61 | | - shirt_count = Application.objects.values('tshirt_size') \ |
62 | | - .annotate(applications=Count('tshirt_size')) |
63 | | - shirt_count_confirmed = Application.objects.filter(status=APP_CONFIRMED).values('tshirt_size') \ |
64 | | - .annotate(applications=Count('tshirt_size')) |
| 67 | + shirt_count_confirmed = map( |
| 68 | + lambda x: {'tshirt_size': tshirt_dict.get(x['tshirt_size'], 'Unknown'), 'applications': x['applications']}, |
| 69 | + Application.objects.filter(status=APP_CONFIRMED).values('tshirt_size') \ |
| 70 | + .annotate(applications=Count('tshirt_size')) |
| 71 | + ) |
65 | 72 |
|
66 | 73 | diet_count = Application.objects.values('diet') \ |
67 | 74 | .annotate(applications=Count('diet')) |
|
0 commit comments