« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/search-select.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/search-select.js')
-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);
     }
   }