session-info

This commit is contained in:
2022-08-12 15:50:59 +03:00
parent 0873304068
commit 9c60318919
4 changed files with 21 additions and 20 deletions

View File

@@ -11,19 +11,15 @@ from sqlalchemy import and_
@query.field("topicsAll")
async def topics_by_slugs(_, info, page = 1, size = 50):
topics = await TopicStorage.get_topics_all(page, size)
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
if "stat" in all_fields:
for topic in topics:
topic.stat = await TopicStat.get_stat(topic.slug)
for topic in topics:
topic.stat = await TopicStat.get_stat(topic.slug)
return topics
@query.field("topicsByCommunity")
async def topics_by_community(_, info, community):
topics = await TopicStorage.get_topics_by_community(community)
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
if "stat" in all_fields:
for topic in topics:
topic.stat = await TopicStat.get_stat(topic.slug)
for topic in topics:
topic.stat = await TopicStat.get_stat(topic.slug)
return topics
@query.field("topicsByAuthor")