@@ -173,30 +173,6 @@ def user_is_talk_manager(self, info: Info) -> bool:
173173 ],
174174 )
175175 def speakers (self , info : Info ) -> list [ScheduleItemUser ]:
176- speakers = []
177-
178- participants_data = info .context ._participants_data
179- if participants_data is None :
180- schedule_items = models .ScheduleItem .objects .filter (
181- conference_id = self .conference_id
182- )
183- submission_speakers = schedule_items .values ("submission__speaker_id" )
184- keynote_speakers = schedule_items .values ("keynote__speakers__user_id" )
185- additional_speakers = schedule_items .values ("additional_speakers__user_id" )
186- participants_data = {
187- participant .user_id : participant
188- for participant in participant_models .Participant .objects .filter (
189- conference_id = self .conference_id
190- )
191- .filter (
192- django_models .Q (user_id__in = submission_speakers )
193- | django_models .Q (user_id__in = keynote_speakers )
194- | django_models .Q (user_id__in = additional_speakers )
195- )
196- .select_related ("user" )
197- }
198- info .context ._participants_data = participants_data
199-
200176 schedule_item_speakers = []
201177 if self .submission_id :
202178 schedule_item_speakers .append (self .submission .speaker )
@@ -209,7 +185,42 @@ def speakers(self, info: Info) -> list[ScheduleItemUser]:
209185 schedule_item_speakers .extend (
210186 speaker .user for speaker in self .additional_speakers .all ()
211187 )
188+ speaker_ids = {
189+ speaker .id for speaker in schedule_item_speakers if speaker is not None
190+ }
212191
192+ participants_by_conference = info .context ._participants_data
193+ if participants_by_conference is None :
194+ participants_by_conference = {}
195+ info .context ._participants_data = participants_by_conference
196+
197+ participants_data = participants_by_conference .setdefault (
198+ self .conference_id , {}
199+ )
200+ if not speaker_ids .issubset (participants_data ):
201+ participants_data .update ({speaker_id : None for speaker_id in speaker_ids })
202+ schedule_items = models .ScheduleItem .objects .filter (
203+ conference_id = self .conference_id
204+ )
205+ submission_speakers = schedule_items .values ("submission__speaker_id" )
206+ keynote_speakers = schedule_items .values ("keynote__speakers__user_id" )
207+ additional_speakers = schedule_items .values ("additional_speakers__user_id" )
208+ participants_data .update (
209+ {
210+ participant .user_id : participant
211+ for participant in participant_models .Participant .objects .filter (
212+ conference_id = self .conference_id
213+ )
214+ .filter (
215+ django_models .Q (user_id__in = submission_speakers )
216+ | django_models .Q (user_id__in = keynote_speakers )
217+ | django_models .Q (user_id__in = additional_speakers )
218+ )
219+ .select_related ("user" )
220+ }
221+ )
222+
223+ speakers = []
213224 for speaker in schedule_item_speakers :
214225 if speaker is None :
215226 continue
0 commit comments