diff --git a/schema.graphql b/schema.graphql index dd3a1121..6a4f4cbd 100644 --- a/schema.graphql +++ b/schema.graphql @@ -253,6 +253,7 @@ type Query { topicsByAuthor(author: String!): [Topic]! # collections + collectionsAll: [Collection]! getUserCollections(author: String!): [Collection]! shoutsByCollection(collection: String!, page: Int, size: Int): [Shout]! @@ -429,7 +430,7 @@ type Collection { slug: String! title: String! desc: String - pic: String! + amount: Int publishedAt: DateTime createdAt: DateTime! createdBy: User! diff --git a/services/stat/topicstat.py b/services/stat/topicstat.py index 676b9cb0..544c63c4 100644 --- a/services/stat/topicstat.py +++ b/services/stat/topicstat.py @@ -5,7 +5,6 @@ from services.stat.viewed import ViewedStorage from services.zine.shoutauthor import ShoutAuthorStorage from orm.topic import ShoutTopic, TopicFollower from typing import Dict - class TopicStat: shouts_by_topic = {} authors_by_topic = {} @@ -18,14 +17,14 @@ class TopicStat: self = TopicStat self.shouts_by_topic = {} self.authors_by_topic = {} - shout_topics = session.query(ShoutTopic) + shout_topics = session.query(ShoutTopic).all() for shout_topic in shout_topics: topic = shout_topic.topic shout = shout_topic.shout if topic in self.shouts_by_topic: self.shouts_by_topic[topic].append(shout) else: - self.shouts_by_topic[topic] = [shout] + self.shouts_by_topic[topic] = [shout, ] authors = await ShoutAuthorStorage.get_authors(shout) if topic in self.authors_by_topic: @@ -66,7 +65,9 @@ class TopicStat: "authors" : len(authors), "followers" : len(followers), "viewed": await ViewedStorage.get_topic(topic), - "reacted" : await ReactedStorage.get_topic(topic), + "reacted" : len(await ReactedStorage.get_topic(topic)), + "commented": len(await ReactedStorage.get_topic_comments(topic)), + "bookmarked": len(await ReactedStorage.get_topic_bookmarked(topic)), "rating" : await ReactedStorage.get_topic_rating(topic), }