From cabc74f5cde00f727e37204a706fe4014c7ce4b0 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 27 Jul 2022 18:58:57 +0200 Subject: [PATCH] Fix admin profile --- app/admin.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/app/admin.py b/app/admin.py index f820e74..791a8af 100644 --- a/app/admin.py +++ b/app/admin.py @@ -513,18 +513,31 @@ async def admin_profile( actors_metadata = await get_actors_metadata(db_session, [actor]) inbox_objects = ( - await db_session.scalars( - select(models.InboxObject) - .where( - models.InboxObject.is_deleted.is_(False), - models.InboxObject.actor_id == actor.id, - models.InboxObject.ap_type.in_( - ["Note", "Article", "Video", "Page", "Announce"] - ), + ( + await db_session.scalars( + select(models.InboxObject) + .where( + models.InboxObject.is_deleted.is_(False), + models.InboxObject.actor_id == actor.id, + models.InboxObject.ap_type.in_( + ["Note", "Article", "Video", "Page", "Announce"] + ), + ) + .options( + joinedload(models.InboxObject.relates_to_inbox_object), + joinedload(models.InboxObject.relates_to_outbox_object).options( + joinedload( + models.OutboxObject.outbox_object_attachments + ).options(joinedload(models.OutboxObjectAttachment.upload)), + ), + joinedload(models.InboxObject.actor), + ) + .order_by(models.InboxObject.ap_published_at.desc()) ) - .order_by(models.InboxObject.ap_published_at.desc()) ) - ).all() + .unique() + .all() + ) return await templates.render_template( db_session,