get_topics_all no page and size

This commit is contained in:
tonyrewin 2022-09-05 16:28:21 +03:00
parent 114b2d8b0f
commit 68096b21a4
2 changed files with 5 additions and 7 deletions

View File

@ -11,8 +11,8 @@ import random
@query.field("topicsAll") @query.field("topicsAll")
async def topics_all(_, info, page=1, size=50): async def topics_all(_, info):
topics = await TopicStorage.get_topics_all(page, size) topics = await TopicStorage.get_topics_all()
for topic in topics: for topic in topics:
topic.stat = await TopicStat.get_stat(topic.slug) topic.stat = await TopicStat.get_stat(topic.slug)
return topics return topics
@ -86,7 +86,7 @@ def topic_unfollow(user, slug):
@query.field("topicsRandom") @query.field("topicsRandom")
async def topics_random(_, info): async def topics_random(_, info):
topics = await TopicStorage.get_topics_all(1, 700) topics = await TopicStorage.get_topics_all()
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)

View File

@ -27,12 +27,10 @@ class TopicStorage:
return topic return topic
@staticmethod @staticmethod
async def get_topics_all(page, size): async def get_topics_all():
end = page * size
start = end - size
self = TopicStorage self = TopicStorage
async with self.lock: async with self.lock:
return list(self.topics.values())[start:end] return list(self.topics.values())
@staticmethod @staticmethod
async def get_topics_by_slugs(slugs): async def get_topics_by_slugs(slugs):