-reactions.storage, +collectionShouts.query, fixes

This commit is contained in:
2022-08-13 12:48:07 +03:00
parent 5859a4db40
commit f0b625af53
19 changed files with 277 additions and 381 deletions

View File

@@ -1,3 +1,4 @@
from orm.collection import ShoutCollection
from orm.shout import Shout, ShoutAuthor, ShoutTopic
from orm.topic import Topic
from base.orm import local_session
@@ -81,6 +82,18 @@ async def shouts_by_topics(_, info, slugs, page, size):
offset(page * size)
return shouts
@query.field("shoutsByCollection")
async def shouts_by_topics(_, info, collection, page, size):
page = page - 1
with local_session() as session:
shouts = session.query(Shout).\
join(ShoutCollection, ShoutCollection.collection == collection).\
where(and_(ShoutCollection.shout == Shout.slug, Shout.publishedAt != None)).\
order_by(desc(Shout.publishedAt)).\
limit(size).\
offset(page * size)
return shouts
@query.field("shoutsByAuthors")
async def shouts_by_authors(_, info, slugs, page, size):
page = page - 1