Skip to content

Commit

Permalink
chore: If already in todolist, don't add.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovler-Young committed Jun 29, 2024
1 parent 9fe6784 commit 605d0c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/server/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,21 @@ 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 {
const messageText = `Processing source ${source_type} ${source_id}:\n` +
`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 = {};
Expand Down Expand Up @@ -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++;
}
Expand Down

0 comments on commit 605d0c5

Please sign in to comment.