removed redundant fetch
This commit is contained in:
parent
0a6b98ce51
commit
9b4fe456e8
|
@ -35,8 +35,6 @@ async def get_publication(publication_id: UUID):
|
|||
publication = await prefetch_publication_relations(
|
||||
Publication.get(id=publication_id).first()
|
||||
)
|
||||
# TODO: this is redundant but there's some prefetch problem otherwise
|
||||
publication.event = await get_event(publication.event.mobilizon_id)
|
||||
return EventPublication.from_orm(
|
||||
event=MobilizonEvent.from_model(publication.event), model=publication
|
||||
)
|
||||
|
|
|
@ -43,7 +43,12 @@ async def prefetch_publication_relations(
|
|||
queryset: QuerySet[Publication],
|
||||
) -> list[Publication]:
|
||||
publication = (
|
||||
await queryset.prefetch_related("publisher", "event")
|
||||
await queryset.prefetch_related(
|
||||
"publisher",
|
||||
"event",
|
||||
"event__publications",
|
||||
"event__publications__publisher",
|
||||
)
|
||||
.order_by("timestamp")
|
||||
.distinct()
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue