aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/helpers/rss.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-02-13 18:15:07 +0100
committerArmand Philippot <git@armandphilippot.com>2022-02-13 19:12:22 +0100
commit43f1fc3ce52e6ddd397853964c8868f2f4eee41d (patch)
tree1c631893cd79c4f2be048e4f7c36a4e2671e5f44 /src/utils/helpers/rss.ts
parent65bf38646c303399daf0766a10dc7893b78d8301 (diff)
chore: improve RSS feed generation time
Diffstat (limited to 'src/utils/helpers/rss.ts')
-rw-r--r--src/utils/helpers/rss.ts15
1 files changed, 5 insertions, 10 deletions
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<ArticlePreview[]> => {
+ 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;
};