feat: filter artist discography + counts to core releases unless showAllTypes

This commit is contained in:
Jonathan
2026-07-11 18:05:46 +02:00
parent f2dbef047c
commit 560fdaa4b0
6 changed files with 110 additions and 18 deletions
+16
View File
@@ -0,0 +1,16 @@
import { describe, it, expect } from "vitest";
import { isCoreRelease } from "./release-filter";
describe("isCoreRelease", () => {
it("accepts Album/Single/EP with no secondary types", () => {
expect(isCoreRelease({ primaryType: "Album", secondaryTypes: [] })).toBe(true);
expect(isCoreRelease({ primaryType: "Single", secondaryTypes: [] })).toBe(true);
expect(isCoreRelease({ primaryType: "EP", secondaryTypes: [] })).toBe(true);
});
it("rejects secondary types and non-core primaries and null", () => {
expect(isCoreRelease({ primaryType: "Album", secondaryTypes: ["Live"] })).toBe(false);
expect(isCoreRelease({ primaryType: "Album", secondaryTypes: ["Compilation"] })).toBe(false);
expect(isCoreRelease({ primaryType: "Broadcast", secondaryTypes: [] })).toBe(false);
expect(isCoreRelease({ primaryType: null, secondaryTypes: [] })).toBe(false);
});
});
+6
View File
@@ -0,0 +1,6 @@
const CORE_PRIMARY = new Set(["Album", "Single", "EP"]);
/** A "core" studio release: Album/Single/EP with no secondary types (live, compilation, etc.). */
export function isCoreRelease(r: { primaryType: string | null; secondaryTypes: string[] }): boolean {
return CORE_PRIMARY.has(r.primaryType ?? "") && r.secondaryTypes.length === 0;
}