diff --git a/packages/backend/routes/song/info.ts b/packages/backend/routes/song/info.ts index 9e7d7f3..427e4da 100644 --- a/packages/backend/routes/song/info.ts +++ b/packages/backend/routes/song/info.ts @@ -134,7 +134,10 @@ const songInfoUpdateHandler = new Elysia({ prefix: "/song" }).use(requireAuth).p objectId: songID, changeType: "update-song", changedBy: user!.unqId, - data: updatedData.length > 0 ? updatedData[0] : null + data: updatedData.length > 0 ? { + old: info, + new: updatedData[0] + } : null }); return { message: "Successfully updated song info.", diff --git a/packages/crawler/mq/task/collectSongs.ts b/packages/crawler/mq/task/collectSongs.ts index 894fb79..8ce4a0d 100644 --- a/packages/crawler/mq/task/collectSongs.ts +++ b/packages/crawler/mq/task/collectSongs.ts @@ -34,23 +34,24 @@ export async function insertIntoSongs(aid: number) { .returning(); return data; } - const data = await db - .insert(songs) - .values({ - aid, - publishedAt: drizzleSQL`SELECT published_at FROM bilibili_metadata WHERE aid = ${aid}`, - duration: drizzleSQL`SELECT duration FROM bilibili_metadata WHERE aid = ${aid}`, - image: drizzleSQL`SELECT cover_url FROM bilibili_metadata WHERE aid = ${aid}`, - producer: drizzleSQL` - SELECT username - FROM bilibili_user bu - JOIN bilibili_metadata bm - ON bm.uid = bu.uid - WHERE bm.aid = ${aid} - ` - }) - .onConflictDoNothing() - .returning(); + const data = await sql` + INSERT INTO songs (aid, published_at, duration, image, producer) + VALUES ( + $1, + (SELECT published_at FROM bilibili_metadata WHERE aid = ${aid}), + (SELECT duration FROM bilibili_metadata WHERE aid = ${aid}), + (SELECT cover_url FROM bilibili_metadata WHERE aid = ${aid}), + ( + SELECT username + FROM bilibili_user bu + JOIN bilibili_metadata bm + ON bm.uid = bu.uid + WHERE bm.aid = ${aid} + ) + ) + ON CONFLICT DO NOTHING + RETURNING * + ` return data; } diff --git a/packages/crawler/src/bullui.ts b/packages/crawler/src/bullui.ts index 2d55344..714bde9 100644 --- a/packages/crawler/src/bullui.ts +++ b/packages/crawler/src/bullui.ts @@ -21,8 +21,8 @@ const app = express(); app.use("/", serverAdapter.getRouter()); -app.listen(5000, () => { - console.log("Running on 5000..."); - console.log("For the UI, open http://localhost:5000/"); +app.listen(5086, () => { + console.log("Running on 5086..."); + console.log("For the UI, open http://localhost:5086/"); console.log("Make sure Redis is running on port 6379 by default"); });