diff --git a/resolvers/profile.py b/resolvers/profile.py index 3f5e09b7..8d6297f8 100644 --- a/resolvers/profile.py +++ b/resolvers/profile.py @@ -160,5 +160,8 @@ def author_unfollow(user, slug): session.commit() @query.field("authorsAll") -def get_authors_all(_, info): - return UserStorage.get_all_users() +def get_authors_all(_, info, page, size): + end = page * size + start = end - size + return UserStorage.get_all_users()[start:end] + diff --git a/resolvers/topics.py b/resolvers/topics.py index 148d401d..dc453adc 100644 --- a/resolvers/topics.py +++ b/resolvers/topics.py @@ -9,7 +9,7 @@ from auth.authenticate import login_required from sqlalchemy import and_ @query.field("topicsAll") -async def topics_by_slugs(_, info, page = 1, size = 50): +async def topics_all(_, info, page = 1, size = 50): topics = await TopicStorage.get_topics_all(page, size) for topic in topics: topic.stat = await TopicStat.get_stat(topic.slug) diff --git a/schema.graphql b/schema.graphql index e7000438..8130e88e 100644 --- a/schema.graphql +++ b/schema.graphql @@ -221,7 +221,7 @@ type Query { userFollowedCommunities(slug: String!): [Community]! userReactedShouts(slug: String!): [Shout]! # test getUserRoles(slug: String!): [Role]! - authorsAll: [User]! + authorsAll(page: Int!, size: Int!): [User]! # shouts getShoutBySlug(slug: String!): Shout! diff --git a/services/zine/topics.py b/services/zine/topics.py index bda5e604..6815ef68 100644 --- a/services/zine/topics.py +++ b/services/zine/topics.py @@ -27,10 +27,12 @@ class TopicStorage: return topic @staticmethod - async def get_topics_all(): + async def get_topics_all(page, size): + end = page * size + start = end - size self = TopicStorage async with self.lock: - return self.topics.values() + return self.topics.values()[start:end] @staticmethod async def get_topics_by_slugs(slugs):