counters fix
This commit is contained in:
parent
1254b14163
commit
68fd4d9936
|
@ -253,6 +253,7 @@ type Query {
|
||||||
topicsByAuthor(author: String!): [Topic]!
|
topicsByAuthor(author: String!): [Topic]!
|
||||||
|
|
||||||
# collections
|
# collections
|
||||||
|
collectionsAll: [Collection]!
|
||||||
getUserCollections(author: String!): [Collection]!
|
getUserCollections(author: String!): [Collection]!
|
||||||
shoutsByCollection(collection: String!, page: Int, size: Int): [Shout]!
|
shoutsByCollection(collection: String!, page: Int, size: Int): [Shout]!
|
||||||
|
|
||||||
|
@ -429,7 +430,7 @@ type Collection {
|
||||||
slug: String!
|
slug: String!
|
||||||
title: String!
|
title: String!
|
||||||
desc: String
|
desc: String
|
||||||
pic: String!
|
amount: Int
|
||||||
publishedAt: DateTime
|
publishedAt: DateTime
|
||||||
createdAt: DateTime!
|
createdAt: DateTime!
|
||||||
createdBy: User!
|
createdBy: User!
|
||||||
|
|
|
@ -5,7 +5,6 @@ from services.stat.viewed import ViewedStorage
|
||||||
from services.zine.shoutauthor import ShoutAuthorStorage
|
from services.zine.shoutauthor import ShoutAuthorStorage
|
||||||
from orm.topic import ShoutTopic, TopicFollower
|
from orm.topic import ShoutTopic, TopicFollower
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
class TopicStat:
|
class TopicStat:
|
||||||
shouts_by_topic = {}
|
shouts_by_topic = {}
|
||||||
authors_by_topic = {}
|
authors_by_topic = {}
|
||||||
|
@ -18,14 +17,14 @@ class TopicStat:
|
||||||
self = TopicStat
|
self = TopicStat
|
||||||
self.shouts_by_topic = {}
|
self.shouts_by_topic = {}
|
||||||
self.authors_by_topic = {}
|
self.authors_by_topic = {}
|
||||||
shout_topics = session.query(ShoutTopic)
|
shout_topics = session.query(ShoutTopic).all()
|
||||||
for shout_topic in shout_topics:
|
for shout_topic in shout_topics:
|
||||||
topic = shout_topic.topic
|
topic = shout_topic.topic
|
||||||
shout = shout_topic.shout
|
shout = shout_topic.shout
|
||||||
if topic in self.shouts_by_topic:
|
if topic in self.shouts_by_topic:
|
||||||
self.shouts_by_topic[topic].append(shout)
|
self.shouts_by_topic[topic].append(shout)
|
||||||
else:
|
else:
|
||||||
self.shouts_by_topic[topic] = [shout]
|
self.shouts_by_topic[topic] = [shout, ]
|
||||||
|
|
||||||
authors = await ShoutAuthorStorage.get_authors(shout)
|
authors = await ShoutAuthorStorage.get_authors(shout)
|
||||||
if topic in self.authors_by_topic:
|
if topic in self.authors_by_topic:
|
||||||
|
@ -66,7 +65,9 @@ class TopicStat:
|
||||||
"authors" : len(authors),
|
"authors" : len(authors),
|
||||||
"followers" : len(followers),
|
"followers" : len(followers),
|
||||||
"viewed": await ViewedStorage.get_topic(topic),
|
"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),
|
"rating" : await ReactedStorage.get_topic_rating(topic),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user