From 208c7d380aea4c02e86ea89199e69118a1af27b9 Mon Sep 17 00:00:00 2001 From: April John Date: Wed, 24 May 2023 20:21:15 +0200 Subject: [PATCH] update post import --- packages/backend/src/queue/initialize.ts | 2 ++ .../backend/src/queue/processors/db/import-masto-post.ts | 9 +++++++-- packages/backend/src/queue/queues.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index d7945d5dad..0686fe9cd3 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -19,6 +19,8 @@ export function initialize(name: string, limitPerSec = -1) { } : undefined, settings: { + stalledInterval: 60, + maxStalledCount: 2, backoffStrategies: { apBackoff, }, diff --git a/packages/backend/src/queue/processors/db/import-masto-post.ts b/packages/backend/src/queue/processors/db/import-masto-post.ts index 564071d3bb..317ba7b1bd 100644 --- a/packages/backend/src/queue/processors/db/import-masto-post.ts +++ b/packages/backend/src/queue/processors/db/import-masto-post.ts @@ -20,9 +20,11 @@ export async function importMastoPost( } const post = job.data.post; let reply: Note | null = null; + job.progress(20); if (post.object.inReplyTo != null) { reply = await resolveNote(post.object.inReplyTo); } + job.progress(40); if (post.directMessage) { done(); return; @@ -33,13 +35,14 @@ export async function importMastoPost( return; } } + job.progress(60); let text; try { text = htmlToMfm(post.object.content, post.object.tag); } catch (e) { throw e; } - + job.progress(80); const note = await create(user, { createdAt: new Date(post.object.published), files: undefined, @@ -56,6 +59,8 @@ export async function importMastoPost( apHashtags: undefined, apEmojis: undefined, }); - logger.succ("Imported"); + job.progress(100); done(); + + logger.succ("Imported"); } diff --git a/packages/backend/src/queue/queues.ts b/packages/backend/src/queue/queues.ts index 6d7fffcb30..6b0eb2de42 100644 --- a/packages/backend/src/queue/queues.ts +++ b/packages/backend/src/queue/queues.ts @@ -20,7 +20,7 @@ export const inboxQueue = initializeQueue( "inbox", config.inboxJobPerSec || 16, ); -export const dbQueue = initializeQueue("db"); +export const dbQueue = initializeQueue("db", 256); export const objectStorageQueue = initializeQueue("objectStorage"); export const webhookDeliverQueue = initializeQueue(