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

View File

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