module
pretalx.person.domain.queries.user
Functions 1
with_profiles(qs, event)sourcePrefetch the user's SpeakerProfile for event onto _speakers so User.get_speaker can hit the cache.
def with_profiles(qs, event):
"""Prefetch the user's :class:`SpeakerProfile` for ``event`` onto
``_speakers`` so :meth:`User.get_speaker` can hit the cache."""
return qs.prefetch_related(
models.Prefetch(
"profiles",
queryset=SpeakerProfile.objects.filter(event=event).select_related("event"),
to_attr="_speakers",
)
).distinct()