diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-01-12 07:47:00 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-01-12 07:47:00 -0400 |
| commit | f177fba63f3d42c45b16a0b6246b7c2f7726e6ca (patch) | |
| tree | 075b8711f6ce93711ecd73d361efb09c468f426a | |
| parent | 77a914d63db487cfeeee36cfd519d05c4f410438 (diff) | |
search-select: also consider total contributions to groups preview
| -rw-r--r-- | src/search-select.js | 29 |
1 files changed, 18 insertions, 11 deletions
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()); |