diff --git a/.idea/data_source_mapping.xml b/.idea/data_source_mapping.xml index 5bd28e0..e4023f1 100644 --- a/.idea/data_source_mapping.xml +++ b/.idea/data_source_mapping.xml @@ -15,6 +15,7 @@ + diff --git a/packages/crawler/mq/exec/getVideoInfo.ts b/packages/crawler/mq/exec/getVideoInfo.ts index f832a0e..b4ba86d 100644 --- a/packages/crawler/mq/exec/getVideoInfo.ts +++ b/packages/crawler/mq/exec/getVideoInfo.ts @@ -70,26 +70,24 @@ export const getVideoInfoWorker = async (job: Job): Promise uid: uid, }); - const userExists = await userExistsInBiliUsers(aid); - if (!userExists) { - await db.insert(bilibiliUser).values({ + await db + .insert(bilibiliUser) + .values({ avatar: data.View.owner.face, desc: data.Card.card.sign, fans: data.Card.follower, uid, username: data.View.owner.name, - }); - } else { - await db - .update(bilibiliUser) - .set({ + }) + .onConflictDoUpdate({ + set: { avatar: data.View.owner.face, desc: data.Card.card.sign, fans: data.Card.follower, username: data.View.owner.name, - }) - .where(eq(bilibiliUser.uid, uid)); - } + }, + target: bilibiliUser.uid, + }); const stat = data.View.stat;