revised
This commit is contained in:
@@ -129,3 +129,7 @@ def get_subscribed_shout_comments(slug):
|
||||
all()
|
||||
slugs = [row.shout for row in rows]
|
||||
return slugs
|
||||
|
||||
def get_top10_comments():
|
||||
with local_session() as session:
|
||||
rows = session.query(Comment).limit(10).all()
|
||||
|
@@ -98,17 +98,18 @@ async def user_comments(_, info, slug, page, size):
|
||||
|
||||
return comments
|
||||
|
||||
@query.field("userSubscriptions")
|
||||
@query.field("userSubscribedAuthors")
|
||||
async def user_subscriptions(_, info, slug):
|
||||
return _get_user_subscribed_authors(slug)
|
||||
slugs = _get_user_subscribed_authors(slug)
|
||||
return slugs
|
||||
|
||||
@query.field("userSubscribers")
|
||||
async def user_subscribers(_, info, slug):
|
||||
with local_session() as session:
|
||||
users = session.query(User).\
|
||||
slugs = session.query(User.slug).\
|
||||
join(AuthorSubscription, User.slug == AuthorSubscription.subscriber).\
|
||||
where(AuthorSubscription.author == slug)
|
||||
return users
|
||||
return slugs
|
||||
|
||||
@query.field("userSubscribedTopics")
|
||||
async def user_subscribed_topics(_, info, slug):
|
||||
|
@@ -13,16 +13,21 @@ async def topics_by_slugs(_, info, slugs = None):
|
||||
with local_session() as session:
|
||||
topics = await TopicStorage.get_topics(slugs)
|
||||
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
|
||||
if "topicStat" in all_fields:
|
||||
if "stat" in all_fields:
|
||||
for topic in topics:
|
||||
topic.topicStat = await TopicStat.get_stat(topic.slug)
|
||||
topic.stat = await TopicStat.get_stat(topic.slug)
|
||||
return topics
|
||||
|
||||
@query.field("topicsByCommunity")
|
||||
async def topics_by_community(_, info, community):
|
||||
with local_session() as session:
|
||||
return await TopicStorage.get_topics_by_community(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)
|
||||
return topics
|
||||
|
||||
@query.field("topicsByAuthor")
|
||||
async def topics_by_author(_, info, author):
|
||||
slugs = set()
|
||||
|
Reference in New Issue
Block a user