« get me outta code hell

search: fresher artist groups math - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-11-03 14:38:23 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-11-03 14:38:23 -0400
commita83fc7f8c0f8a4b4d8e08c90275369f23b6821db (patch)
treeb8108f304f1564a3b864338e92d8cbf92c8464e2 /src
parenta2a4b8b566114cecb2fd9d3d5a9e0351e521f0f9 (diff)
search: fresher artist groups math
Diffstat (limited to 'src')
-rw-r--r--src/search-select.js35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/search-select.js b/src/search-select.js
index db347914..02002057 100644
--- a/src/search-select.js
+++ b/src/search-select.js
@@ -62,32 +62,41 @@ function determineArtistGroups(artist, opts) {
   const contributionGroups =
     contributions.flatMap(contrib => contrib.groups);
 
+  const scores =
+    new Map(
+      unique(contributionGroups).map(group => [group, 0]));
+
   const artistNamesish =
     unique(
       [artist.name, ...artist.artistAliases.map(alias => alias.name)]
         .map(name => getKebabCase(name)));
 
-  const interestingGroups =
-    unique(contributionGroups)
-      .filter(group => !artistNamesish.includes(getKebabCase(group.name)));
+  for (const group of scores.keys()) {
+    if (artistNamesish.includes(getKebabCase(group.name))) {
+      scores.delete(group);
+    }
+  }
 
-  if (contributions.length < 50) {
-    return interestingGroups;
+  for (const group of contributionGroups) {
+    scores.set(group, scores.get(group) + 1 / contributions.length);
   }
 
   const dividingGroups =
     opts.wikiInfo.divideTrackListsByGroups;
 
-  const scores =
-    new Map(interestingGroups.map(group => [group, 0]));
+  const dividingGroupThreshold =
+    (contributions.length < 50 ? 0.08 : 0.16);
 
-  for (const group of contributionGroups) {
-    scores.set(group, scores.get(group) + 1 / contributions.length);
-  }
+  const generalGroupThreshold =
+    (contributions.length < 50 ? 0.00 : 0.12);
+
+  for (const group of scores.keys()) {
+    const threshold =
+      (dividingGroups.includes(group)
+        ? dividingGroupThreshold
+        : generalGroupThreshold);
 
-  for (const group of interestingGroups) {
-    if (dividingGroups.includes(group)) continue;
-    if (scores.get(group) < 0.12) {
+    if (scores.get(group) < threshold) {
       scores.delete(group);
     }
   }