diff options
author | Alban Gruin | 2017-01-28 13:20:23 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-28 13:20:23 +0100 |
commit | ebb7c3bf0dc3eef2efa3f4add60ccfc7dc063248 (patch) | |
tree | 089d20c831cfc7f02b2b65beca6f78b8f1a59943 /views.py | |
parent | dfb352540ce5a66ef475f0c6d855fc2f322d553a (diff) |
Traitement des semaines avec un group by, semblant diviser par deux le temps de traitement
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -18,18 +18,17 @@ def index(request): current_year, current_week, _ = timezone.now().isocalendar() start, _ = get_week(current_year, current_week) + groups_weeks = Course.objects.get_weeks(begin__gte=start).values("groups__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week") for group in groups: - courses = Course.objects.get_courses_for_group(group, begin__gte=start).values("begin").annotate(count=Count("begin")) - weeks = [] - for course in courses: - year, week, _ = course["begin"].isocalendar() - date, _ = get_week(year, week) - - if date not in weeks: - weeks.append(date) - - group.weeks = weeks + for group_week in groups_weeks: + if group.corresponds_to(group_week["groups__timetable"], group_week["groups__mention"], group_week["groups__subgroup"], group_week["groups__td"], group_week["groups__tp"]): + if not hasattr(group, "weeks"): + group.weeks = [] + + date, _ = get_week(group_week["year"], group_week["week"]) + if date not in group.weeks: + group.weeks.append(date) return render(request, "index.html", {"timetables": timetables, "groups": groups}) |