diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-13 18:15:07 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-13 19:12:22 +0100 |
| commit | 43f1fc3ce52e6ddd397853964c8868f2f4eee41d (patch) | |
| tree | 1c631893cd79c4f2be048e4f7c36a4e2671e5f44 /src/utils/helpers/rss.ts | |
| parent | 65bf38646c303399daf0766a10dc7893b78d8301 (diff) | |
chore: improve RSS feed generation time
Diffstat (limited to 'src/utils/helpers/rss.ts')
| -rw-r--r-- | src/utils/helpers/rss.ts | 15 |
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; }; |
