shoutsByLayout
This commit is contained in:
@@ -57,6 +57,7 @@ from resolvers.zine import (
|
||||
recent_reacted,
|
||||
shouts_by_authors,
|
||||
shouts_by_topics,
|
||||
shouts_by_layout,
|
||||
shouts_by_communities,
|
||||
)
|
||||
|
||||
@@ -91,6 +92,7 @@ __all__ = [
|
||||
"recent_reacted",
|
||||
"recent_all",
|
||||
"shouts_by_topics",
|
||||
"shouts_by_layout",
|
||||
"shouts_by_authors",
|
||||
"shouts_by_communities",
|
||||
"get_user_reacted_shouts",
|
||||
|
@@ -125,6 +125,22 @@ async def shouts_by_authors(_, _info, slugs, offset=0, limit=100):
|
||||
return shouts_prepared[offset : offset + limit]
|
||||
|
||||
|
||||
@query.field("shoutsByLayout")
|
||||
async def shouts_by_layout(_, _info, layout, amount=100, offset=0):
|
||||
async with ShoutsCache.lock:
|
||||
shouts = {}
|
||||
# for layout in ['image', 'audio', 'video', 'literature']:
|
||||
shouts_by_layout = list(ShoutsCache.by_layout.get(layout, []))
|
||||
for s in shouts_by_layout:
|
||||
for a in s.authors:
|
||||
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
|
||||
# if bool(s.publishedAt):
|
||||
shouts[s.slug] = s
|
||||
shouts_prepared = list(shouts.values())
|
||||
shouts_prepared.sort(key=lambda s: s.createdAt, reverse=True)
|
||||
return shouts_prepared[offset : offset + amount]
|
||||
|
||||
|
||||
@query.field("shoutsByTopics")
|
||||
async def shouts_by_topics(_, _info, slugs, offset=0, limit=100):
|
||||
async with ShoutsCache.lock:
|
||||
|
Reference in New Issue
Block a user