From 43f1fc3ce52e6ddd397853964c8868f2f4eee41d Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sun, 13 Feb 2022 18:15:07 +0100 Subject: chore: improve RSS feed generation time --- src/utils/helpers/rss.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/utils') diff --git a/src/utils/helpers/rss.ts b/src/utils/helpers/rss.ts index 305c6e7..8a1c801 100644 --- a/src/utils/helpers/rss.ts +++ b/src/utils/helpers/rss.ts @@ -1,20 +1,15 @@ -import { getPublishedPosts } from '@services/graphql/queries'; +import { getPostsTotal, getPublishedPosts } from '@services/graphql/queries'; import { ArticlePreview } from '@ts/types/articles'; import { PostsList } from '@ts/types/blog'; import { settings } from '@utils/config'; import { Feed } from 'feed'; const getAllPosts = async (): Promise => { + const totalPosts = await getPostsTotal(); const posts: ArticlePreview[] = []; - let hasNextPage = true; - let after = undefined; - - do { - const postsList: PostsList = await getPublishedPosts({ first: 10, after }); - posts.push(...postsList.posts); - hasNextPage = postsList.pageInfo.hasNextPage; - after = postsList.pageInfo.endCursor; - } while (hasNextPage); + + const postsList: PostsList = await getPublishedPosts({ first: totalPosts }); + posts.push(...postsList.posts); return posts; }; -- cgit v1.2.3