mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
perf(sync): parallelize archive task existence checks for bulk updates
This commit is contained in:
parent
c6ceaa5f6b
commit
c49209d364
1 changed files with 8 additions and 6 deletions
|
|
@ -263,12 +263,14 @@ export class ArchiveOperationHandler {
|
|||
const taskArchiveService = this._getTaskArchiveService();
|
||||
|
||||
// Filter to only tasks that exist in archive
|
||||
const archiveUpdates: Update<Task>[] = [];
|
||||
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<Task>[] = taskUpdates.filter(
|
||||
(_, i) => hasTaskResults[i],
|
||||
);
|
||||
|
||||
if (archiveUpdates.length > 0) {
|
||||
await taskArchiveService.updateTasks(archiveUpdates, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue