From 605d0c578802c3a5039dc3d442584846cec64cd6 Mon Sep 17 00:00:00 2001 From: Ovler Date: Sun, 30 Jun 2024 03:24:13 +0800 Subject: [PATCH] chore: If already in todolist, don't add. --- src/lib/server/utils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/server/utils.ts b/src/lib/server/utils.ts index 082dbc4..6d5419d 100644 --- a/src/lib/server/utils.ts +++ b/src/lib/server/utils.ts @@ -164,10 +164,13 @@ const handle_source = async (ctx: Context, source_type: string, source_id: strin const processSource = async () => { let existingCount = 0; let newCount = 0; + let processingCount = 0; let processedCount = 0; let newBvids: string[] = []; let lastMessageText = ''; let lastOptions: any = {}; + const progress = await api.getitems(); + const allBvids = progress.map(item => item.bvid); const updateStatus = async () => { try { @@ -175,6 +178,7 @@ const handle_source = async (ctx: Context, source_type: string, source_id: strin `Total: ${bvids.length}\n` + `${existingCount > 0 ? `Existing: ${existingCount}\n` : ''}` + `${newCount > 0 ? `New: ${newCount}\n` : ''}` + + `${processingCount > 0 ? `Processing: ${processingCount}\n` : ''}` + `${processedCount > 0 ? `Processed: ${processedCount}\n` : ''}`; const options: any = {}; @@ -216,10 +220,12 @@ const handle_source = async (ctx: Context, source_type: string, source_id: strin if (result.isSome()) { existingCount++; - } else { + } else if (!allBvids.includes(bvid)) { newCount++; newBvids.push(bvid); await api.add(new Bvid(bvid)); + } else { + processingCount++; } processedCount++; }