From c49209d364338914484ebf5bb5f177279be5b862 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Tue, 20 Jan 2026 18:22:43 +0100 Subject: [PATCH] perf(sync): parallelize archive task existence checks for bulk updates --- .../apply/archive-operation-handler.service.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/op-log/apply/archive-operation-handler.service.ts b/src/app/op-log/apply/archive-operation-handler.service.ts index 3d44039ec..444020168 100644 --- a/src/app/op-log/apply/archive-operation-handler.service.ts +++ b/src/app/op-log/apply/archive-operation-handler.service.ts @@ -263,12 +263,14 @@ export class ArchiveOperationHandler { const taskArchiveService = this._getTaskArchiveService(); // Filter to only tasks that exist in archive - const archiveUpdates: Update[] = []; - for (const update of taskUpdates) { - if (await taskArchiveService.hasTask(update.id as string)) { - archiveUpdates.push(update); - } - } + // Check all tasks in parallel for better performance + const hasTaskResults = await Promise.all( + taskUpdates.map((update) => taskArchiveService.hasTask(update.id as string)), + ); + + const archiveUpdates: Update[] = taskUpdates.filter( + (_, i) => hasTaskResults[i], + ); if (archiveUpdates.length > 0) { await taskArchiveService.updateTasks(archiveUpdates, {