From f177fba63f3d42c45b16a0b6246b7c2f7726e6ca Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 12 Jan 2026 07:47:00 -0400 Subject: search-select: also consider total contributions to groups --- src/search-select.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/search-select.js b/src/search-select.js index fcc1e7d6..4470c463 100644 --- a/src/search-select.js +++ b/src/search-select.js @@ -63,9 +63,11 @@ function determineArtistGroups(artist, opts) { const contributionGroups = contributions.flatMap(contrib => contrib.groups); - const scores = - new Map( - unique(contributionGroups).map(group => [group, 0])); + const groupToZero = + new Map(unique(contributionGroups).map(group => [group, 0])); + + const scores = new Map(groupToZero); + const counts = new Map(groupToZero); const artistNames = [artist, ...artist.artistAliases] @@ -76,6 +78,7 @@ function determineArtistGroups(artist, opts) { for (const artistName of artistNames) { if (compareKebabCase(group.name, artistName)) { scores.delete(group); + counts.delete(group); continue group; } } @@ -83,26 +86,30 @@ function determineArtistGroups(artist, opts) { for (const group of contributionGroups) { scores.set(group, scores.get(group) + 1 / contributions.length); + counts.set(group, counts.get(group) + 1); } const dividingGroups = opts.wikiInfo.divideTrackListsByGroups; - const dividingGroupThreshold = + const dividingGroupScoreThreshold = (contributions.length < 50 ? 0.08 : 0.16); - const generalGroupThreshold = + const generalGroupScoreThreshold = (contributions.length < 50 ? 0.00 : 0.12); + const dividingGroupCountThreshold = 15; + const generalGroupCountThreshold = 20; + for (const group of scores.keys()) { - const threshold = + const [scoreThreshold, countThreshold] = (dividingGroups.includes(group) - ? dividingGroupThreshold - : generalGroupThreshold); + ? [dividingGroupScoreThreshold, dividingGroupCountThreshold] + : [generalGroupScoreThreshold, generalGroupCountThreshold]); - if (scores.get(group) < threshold) { - scores.delete(group); - } + if (scores.get(group) >= scoreThreshold); + else if (counts.get(group) >= countThreshold); + else scores.delete(group); } return Array.from(scores.keys()); -- cgit 1.3.0-6-gf8a5