Skip to content

Commit ca05791

Browse files
committed
Compute session order from available data instead of going through the
database again (saves ~2800 queries on the IETF 106 agenda page) - Legacy-Id: 18414
1 parent 2029fb7 commit ca05791

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ietf/meeting/helpers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44

5+
from collections import defaultdict
56
import datetime
67
import io
78
import os
@@ -197,6 +198,11 @@ def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefe
197198
if a.session.group and a.session.group not in groups:
198199
groups.append(a.session.group)
199200

201+
sessions_for_groups = defaultdict(list)
202+
for a in assignments:
203+
if a.session and a.session.group:
204+
sessions_for_groups[(a.session.group, a.session.type_id)].append(a)
205+
200206
group_replacements = find_history_replacements_active_at(groups, meeting_time)
201207

202208
parent_id_set = set()
@@ -210,7 +216,8 @@ def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefe
210216
if a.session.historic_group.parent_id:
211217
parent_id_set.add(a.session.historic_group.parent_id)
212218

213-
a.session.order_number = a.session.order_in_meeting()
219+
l = sessions_for_groups.get((a.session.group, a.session.type_id), [])
220+
a.session.order_number = l.index(a) + 1 if a in l else 0
214221

215222
parents = Group.objects.filter(pk__in=parent_id_set)
216223
parent_replacements = find_history_replacements_active_at(parents, meeting_time)

0 commit comments

Comments
 (0)