tempfix-random-topics
This commit is contained in:
parent
bd1318dadd
commit
b4561c704d
|
@ -27,7 +27,7 @@ async def topics_by_community(_, info, community):
|
||||||
|
|
||||||
@query.field("topicsByAuthor")
|
@query.field("topicsByAuthor")
|
||||||
async def topics_by_author(_, _info, author):
|
async def topics_by_author(_, _info, author):
|
||||||
topics = await ShoutsCache.get_shouts_by_author(author)
|
topics = ShoutsCache.by_author.get(author)
|
||||||
author_topics = set()
|
author_topics = set()
|
||||||
for tpc in topics:
|
for tpc in topics:
|
||||||
tpc = await TopicStorage.topics[tpc.slug]
|
tpc = await TopicStorage.topics[tpc.slug]
|
||||||
|
@ -87,8 +87,10 @@ async def topics_random(_, info, amount=12):
|
||||||
normalized_topics = []
|
normalized_topics = []
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
topic_stat = await TopicStat.get_stat(topic.slug)
|
topic_stat = await TopicStat.get_stat(topic.slug)
|
||||||
|
# FIXME: expects topicstat fix
|
||||||
|
# #if topic_stat["shouts"] > 2:
|
||||||
|
# normalized_topics.append(topic)
|
||||||
topic.stat = topic_stat
|
topic.stat = topic_stat
|
||||||
if topic_stat["shouts"] > 2:
|
normalized_topics = topics
|
||||||
normalized_topics.append(topic)
|
|
||||||
sample_length = min(len(normalized_topics), amount)
|
sample_length = min(len(normalized_topics), amount)
|
||||||
return random.sample(normalized_topics, sample_length)
|
return random.sample(normalized_topics, sample_length)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user