Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ietf/meeting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,18 @@ def all_meeting_sessions_for_group(self):
from ietf.meeting.utils import add_event_info_to_session_qs
if self.group.features.has_meetings:
if not hasattr(self, "_all_meeting_sessions_for_group_cache"):
sessions = [s for s in add_event_info_to_session_qs(self.meeting.session_set.filter(group=self.group,type=self.type)) if s.official_timeslotassignment()]
self._all_meeting_sessions_for_group_cache = sorted(sessions, key = lambda x: x.official_timeslotassignment().timeslot.time)
sessions = [s for s in add_event_info_to_session_qs(self.meeting.session_set.filter(group=self.group)) if s.official_timeslotassignment()]
for s in sessions:
s.ota = s.official_timeslotassignment()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After approving, noticed that this means official_timeslotassignment() is called twice for each session. Is that cheap enough (or cached effectively by the ORM) not to worry about it? There are only a couple dozen sessions filtered out in the list comprehension so it'd probably be preferable to filter the list after caching s.ota.

# Align this sort with SchedTimeSessAssignment default sort order since many views base their order on that
self._all_meeting_sessions_for_group_cache = sorted(
sessions, key = lambda x: (
x.ota.timeslot.time,
x.ota.timeslot.type.slug,
x.ota.session.group.parent.name if x.ota.session.group.parent else None,
x.ota.session.name
)
)
return self._all_meeting_sessions_for_group_cache
else:
return [self]
Expand Down