fixes-done
This commit is contained in:
parent
b4561c704d
commit
00181e7114
|
@ -88,7 +88,7 @@ class ReactedStorage:
|
||||||
self = ReactedStorage
|
self = ReactedStorage
|
||||||
async with self.lock:
|
async with self.lock:
|
||||||
return list(
|
return list(
|
||||||
filter(lambda r: r.comment, self.reacted["topics"].get(topic_slug, {}))
|
filter(lambda r: r.comment, self.reacted["topics"].get(topic_slug, []))
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -6,6 +6,15 @@ from services.zine.shoutauthor import ShoutAuthorStorage
|
||||||
from orm.topic import ShoutTopic, TopicFollower
|
from orm.topic import ShoutTopic, TopicFollower
|
||||||
|
|
||||||
|
|
||||||
|
def unique(list1):
|
||||||
|
|
||||||
|
# insert the list to the set
|
||||||
|
list_set = set(list1)
|
||||||
|
# convert the set to the list
|
||||||
|
unique_list = (list(list_set))
|
||||||
|
return unique_list
|
||||||
|
|
||||||
|
|
||||||
class TopicStat:
|
class TopicStat:
|
||||||
shouts_by_topic = {}
|
shouts_by_topic = {}
|
||||||
authors_by_topic = {}
|
authors_by_topic = {}
|
||||||
|
@ -16,23 +25,17 @@ class TopicStat:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def load_stat(session):
|
async def load_stat(session):
|
||||||
self = TopicStat
|
self = TopicStat
|
||||||
self.shouts_by_topic = {}
|
|
||||||
self.authors_by_topic = {}
|
|
||||||
shout_topics = session.query(ShoutTopic).all()
|
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 not self.shouts_by_topic.get(topic):
|
if not self.shouts_by_topic.get(topic):
|
||||||
self.shouts_by_topic[topic] = []
|
self.shouts_by_topic[topic] = []
|
||||||
if shout not in self.shouts_by_topic[topic]:
|
|
||||||
self.shouts_by_topic[topic].append(shout)
|
self.shouts_by_topic[topic].append(shout)
|
||||||
|
|
||||||
authors = await ShoutAuthorStorage.get_authors(shout)
|
authors = await ShoutAuthorStorage.get_authors(shout)
|
||||||
if topic in self.authors_by_topic:
|
if not self.authors_by_topic.get(topic):
|
||||||
self.authors_by_topic[topic].update(authors)
|
self.authors_by_topic[topic] = []
|
||||||
else:
|
self.authors_by_topic[topic] = unique(self.authors_by_topic[topic] + authors)
|
||||||
self.authors_by_topic[topic] = list(set(authors))
|
|
||||||
|
|
||||||
print("[stat.topics] authors sorted")
|
print("[stat.topics] authors sorted")
|
||||||
print("[stat.topics] shouts sorted")
|
print("[stat.topics] shouts sorted")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user