« get me outta code hell

content: pre-sort existing listings - 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>2023-07-21 12:15:03 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-07-21 12:15:03 -0300
commit2912e0f77cf3f9f30c49c0ab22abecc9da6fb0db (patch)
treec4745b90f791169d60daa625a7fe82b2a92222cd /src
parentfa57fb3e3a0fd628e134fbe25102cbc3aa8a1c70 (diff)
content: pre-sort existing listings
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/listAlbumsByDuration.js10
-rw-r--r--src/content/dependencies/listAlbumsByTracks.js9
-rw-r--r--src/content/dependencies/listArtistsByCommentaryEntries.js8
-rw-r--r--src/content/dependencies/listArtistsByContributions.js9
-rw-r--r--src/content/dependencies/listArtistsByDuration.js10
-rw-r--r--src/content/dependencies/listGroupsByAlbums.js8
-rw-r--r--src/content/dependencies/listGroupsByDuration.js10
-rw-r--r--src/content/dependencies/listGroupsByTracks.js9
-rw-r--r--src/content/dependencies/listTagsByUses.js17
9 files changed, 71 insertions, 19 deletions
diff --git a/src/content/dependencies/listAlbumsByDuration.js b/src/content/dependencies/listAlbumsByDuration.js
index 650a5d1..3ef5f37 100644
--- a/src/content/dependencies/listAlbumsByDuration.js
+++ b/src/content/dependencies/listAlbumsByDuration.js
@@ -1,5 +1,11 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, getTotalDuration, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  getTotalDuration,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkAlbum'],
@@ -10,7 +16,7 @@ export default {
   },
 
   query({albumData}, spec) {
-    const albums = albumData.slice();
+    const albums = sortAlphabetically(albumData.slice());
     const durations = albums.map(album => getTotalDuration(album.tracks));
 
     filterByCount(albums, durations);
diff --git a/src/content/dependencies/listAlbumsByTracks.js b/src/content/dependencies/listAlbumsByTracks.js
index c31609b..d28a564 100644
--- a/src/content/dependencies/listAlbumsByTracks.js
+++ b/src/content/dependencies/listAlbumsByTracks.js
@@ -1,5 +1,10 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkAlbum'],
@@ -10,7 +15,7 @@ export default {
   },
 
   query({albumData}, spec) {
-    const albums = albumData.slice();
+    const albums = sortAlphabetically(albumData.slice());
     const counts = albums.map(album => album.tracks.length);
 
     filterByCount(albums, counts);
diff --git a/src/content/dependencies/listArtistsByCommentaryEntries.js b/src/content/dependencies/listArtistsByCommentaryEntries.js
index eae6dd6..e3c7094 100644
--- a/src/content/dependencies/listArtistsByCommentaryEntries.js
+++ b/src/content/dependencies/listArtistsByCommentaryEntries.js
@@ -1,5 +1,9 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, sortByCount} from '../../util/wiki-data.js';
+import {
+  filterByCount,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkArtist'],
@@ -10,7 +14,7 @@ export default {
   },
 
   query({artistData}, spec) {
-    const artists = artistData.slice();
+    const artists = sortAlphabetically(artistData.slice());
     const counts =
       artists.map(artist =>
         artist.tracksAsCommentator.length +
diff --git a/src/content/dependencies/listArtistsByContributions.js b/src/content/dependencies/listArtistsByContributions.js
index 442b832..63c8d4b 100644
--- a/src/content/dependencies/listArtistsByContributions.js
+++ b/src/content/dependencies/listArtistsByContributions.js
@@ -1,5 +1,10 @@
 import {stitchArrays, unique} from '../../util/sugar.js';
-import {filterByCount, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkArtist'],
@@ -19,7 +24,7 @@ export default {
     };
 
     const queryContributionInfo = (artistsKey, countsKey, fn) => {
-      const artists = sprawl.artistData.slice();
+      const artists = sortAlphabetically(sprawl.artistData.slice());
       const counts = artists.map(artist => fn(artist));
 
       filterByCount(artists, counts);
diff --git a/src/content/dependencies/listArtistsByDuration.js b/src/content/dependencies/listArtistsByDuration.js
index 478e99b..4c3bd81 100644
--- a/src/content/dependencies/listArtistsByDuration.js
+++ b/src/content/dependencies/listArtistsByDuration.js
@@ -1,5 +1,11 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, getTotalDuration, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  getTotalDuration,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkArtist'],
@@ -10,7 +16,7 @@ export default {
   },
 
   query({artistData}, spec) {
-    const artists = artistData.slice();
+    const artists = sortAlphabetically(artistData.slice());
     const durations = artists.map(artist =>
       getTotalDuration([
         ...(artist.tracksAsArtist ?? []),
diff --git a/src/content/dependencies/listGroupsByAlbums.js b/src/content/dependencies/listGroupsByAlbums.js
index 2235c0d..fac74d9 100644
--- a/src/content/dependencies/listGroupsByAlbums.js
+++ b/src/content/dependencies/listGroupsByAlbums.js
@@ -1,5 +1,9 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, sortByCount} from '../../util/wiki-data.js';
+import {
+  filterByCount,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkGroup'],
@@ -10,7 +14,7 @@ export default {
   },
 
   query({groupData}, spec) {
-    const groups = groupData.slice();
+    const groups = sortAlphabetically(groupData.slice());
     const counts = groups.map(group => group.albums.length);
 
     filterByCount(groups, counts);
diff --git a/src/content/dependencies/listGroupsByDuration.js b/src/content/dependencies/listGroupsByDuration.js
index cf24a47..82ad5af 100644
--- a/src/content/dependencies/listGroupsByDuration.js
+++ b/src/content/dependencies/listGroupsByDuration.js
@@ -1,5 +1,11 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, getTotalDuration, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  getTotalDuration,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkGroup'],
@@ -10,7 +16,7 @@ export default {
   },
 
   query({groupData}, spec) {
-    const groups = groupData.slice();
+    const groups = sortAlphabetically(groupData.slice());
     const durations =
       groups.map(group =>
         getTotalDuration(
diff --git a/src/content/dependencies/listGroupsByTracks.js b/src/content/dependencies/listGroupsByTracks.js
index 35ce153..ab2d459 100644
--- a/src/content/dependencies/listGroupsByTracks.js
+++ b/src/content/dependencies/listGroupsByTracks.js
@@ -1,5 +1,10 @@
 import {accumulateSum, stitchArrays} from '../../util/sugar.js';
-import {filterByCount, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkGroup'],
@@ -10,7 +15,7 @@ export default {
   },
 
   query({groupData}, spec) {
-    const groups = groupData.slice();
+    const groups = sortAlphabetically(groupData.slice());
     const counts =
       groups.map(group =>
         accumulateSum(
diff --git a/src/content/dependencies/listTagsByUses.js b/src/content/dependencies/listTagsByUses.js
index 81b6642..4bc963b 100644
--- a/src/content/dependencies/listTagsByUses.js
+++ b/src/content/dependencies/listTagsByUses.js
@@ -1,5 +1,10 @@
 import {stitchArrays} from '../../util/sugar.js';
-import {filterByCount, sortByCount} from '../../util/wiki-data.js';
+
+import {
+  filterByCount,
+  sortAlphabetically,
+  sortByCount,
+} from '../../util/wiki-data.js';
 
 export default {
   contentDependencies: ['generateListingPage', 'linkArtTag'],
@@ -10,8 +15,14 @@ export default {
   },
 
   query({artTagData}, spec) {
-    const artTags = artTagData.filter(tag => !tag.isContentWarning);
-    const counts = artTags.map(tag => tag.taggedInThings.length);
+    const artTags =
+      sortAlphabetically(
+        artTagData
+          .filter(tag => !tag.isContentWarning));
+
+    const counts =
+      artTags
+        .map(tag => tag.taggedInThings.length);
 
     filterByCount(artTags, counts);
     sortByCount(artTags, counts, {greatestFirst: true});