drafts-ordered

This commit is contained in:
Untone 2024-02-29 15:50:26 +03:00
parent dfbfa9335c
commit 978595c246

View File

@ -1,6 +1,6 @@
import time
from sqlalchemy import and_, select
from sqlalchemy import and_, select, desc
from sqlalchemy.orm import joinedload
from orm.author import Author
@ -31,6 +31,7 @@ async def get_shouts_drafts(_, info):
.options(joinedload(Shout.authors), joinedload(Shout.topics))
.filter(and_(Shout.deleted_at.is_(None), Shout.created_by == author.id))
.filter(Shout.published_at.is_(None))
.order_by(desc(Shout.created_at))
.group_by(Shout.id)
)
shouts = [shout for [shout] in session.execute(q).unique()]