fix(discover): dismissing an artist also dismisses its albums
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,20 @@ describe("discover action API", () => {
|
|||||||
expect((await prisma.discoverySuggestion.findUnique({ where: { id: s.id } }))!.status).toBe("followed");
|
expect((await prisma.discoverySuggestion.findUnique({ where: { id: s.id } }))!.status).toBe("followed");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("dismissing an artist also dismisses its pending album suggestions", async () => {
|
||||||
|
const a = await prisma.discoverySuggestion.create({
|
||||||
|
data: { kind: "artist", artistMbid: "shared", artistName: "Cand", score: 1, seedCount: 1,
|
||||||
|
sources: ["listenbrainz"], secondaryTypes: [], dedupeKey: "artist:shared:" },
|
||||||
|
});
|
||||||
|
const alb = await prisma.discoverySuggestion.create({
|
||||||
|
data: { kind: "album", artistMbid: "shared", artistName: "Cand", rgMbid: "rgS", album: "Rec",
|
||||||
|
albumReason: "newest", score: 1, seedCount: 1, sources: ["listenbrainz"],
|
||||||
|
secondaryTypes: [], dedupeKey: "album:shared:rgS" },
|
||||||
|
});
|
||||||
|
await post(a.id, { action: "dismiss" });
|
||||||
|
expect((await prisma.discoverySuggestion.findUnique({ where: { id: alb.id } }))!.status).toBe("dismissed");
|
||||||
|
});
|
||||||
|
|
||||||
it("want upserts a monitored release from the suggestion and marks wanted", async () => {
|
it("want upserts a monitored release from the suggestion and marks wanted", async () => {
|
||||||
const s = await album("rgW");
|
const s = await album("rgW");
|
||||||
const res = await post(s.id, { action: "want" });
|
const res = await post(s.id, { action: "want" });
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ export async function POST(request: Request, { params }: { params: Promise<{ id:
|
|||||||
|
|
||||||
if (action === "dismiss") {
|
if (action === "dismiss") {
|
||||||
await prisma.discoverySuggestion.update({ where: { id }, data: { status: "dismissed" } });
|
await prisma.discoverySuggestion.update({ where: { id }, data: { status: "dismissed" } });
|
||||||
|
// Dismissing an artist also dismisses its album suggestions, so the whole unified row
|
||||||
|
// disappears cleanly instead of leaving the artist's albums stranded.
|
||||||
|
if (s.kind === "artist") {
|
||||||
|
await prisma.discoverySuggestion.updateMany({
|
||||||
|
where: { kind: "album", artistMbid: s.artistMbid, status: "pending" },
|
||||||
|
data: { status: "dismissed" },
|
||||||
|
});
|
||||||
|
}
|
||||||
return Response.json({ id, status: "dismissed" });
|
return Response.json({ id, status: "dismissed" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user