Improve server startup time

This commit is contained in:
Shadowfacts 2021-01-11 23:14:58 -05:00
parent 96c14c068a
commit aba2496f4f
1 changed files with 2 additions and 1 deletions

View File

@ -9,9 +9,10 @@ const domain = process.env.DOMAIN;
export async function setup(posts: Page[]) { export async function setup(posts: Page[]) {
const repository = getConnection().getRepository(Article); const repository = getConnection().getRepository(Article);
const allPosts = await repository.find();
for (const post of posts) { for (const post of posts) {
const postMeta = <PostMetadata>post.metadata; const postMeta = <PostMetadata>post.metadata;
if (await repository.findOne(postMeta.permalink)) { if (allPosts.some((p) => p.id === postMeta.permalink)) {
continue; continue;
} }
const articleObject = { const articleObject = {