« get me outta code hell

data: Track.countInArtistTotals, Album.countTracksInArtistTotals - 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-06-14 13:27:02 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-06-14 13:27:02 -0300
commit0358b1a448ec25ae319844b47f2db8eefa57ba5f (patch)
treedcffaff9eb7900446547ccc5772b736341c9282a /src
parentb4e2e936a53e0a755ece2f3a03070d1606297e0b (diff)
data: Track.countInArtistTotals, Album.countTracksInArtistTotals
Diffstat (limited to 'src')
-rw-r--r--src/data/things/album.js4
-rw-r--r--src/data/things/track.js27
2 files changed, 31 insertions, 0 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index e27700f4..5132b962 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -97,6 +97,8 @@ export class Album extends Thing {
     alwaysReferenceTracksByDirectory: flag(false),
     suffixTrackDirectories: flag(false),
 
+    countTracksInArtistTotals: flag(true),
+
     color: color(),
     urls: urls(),
 
@@ -502,6 +504,8 @@ export class Album extends Thing {
         transform: String,
       },
 
+      'Count Tracks In Artist Totals': {property: 'countInArtistTotals'},
+
       'Date': {
         property: 'date',
         transform: parseDate,
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 10585ade..8b9420c7 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -170,6 +170,18 @@ export class Track extends Thing {
       exposeDependency({dependency: '#alwaysReferenceByDirectory'}),
     ],
 
+    countInArtistTotals: [
+      exposeUpdateValueOrContinue({
+        validate: input.value(isBoolean),
+      }),
+
+      withPropertyFromAlbum({
+        property: input.value('countTracksInArtistTotals'),
+      }),
+
+      exposeDependency({dependency: '#album.countTracksInArtistTotals'}),
+    ],
+
     // Disables presenting the track as though it has its own unique artwork.
     // This flag should only be used in select circumstances, i.e. to override
     // an album's trackCoverArtists. This flag supercedes that property, as well
@@ -485,6 +497,8 @@ export class Track extends Thing {
         transform: String,
       },
 
+      'Count In Artist Totals': {property: 'countInArtistTotals'},
+
       'Duration': {
         property: 'duration',
         transform: parseDuration,
@@ -603,6 +617,11 @@ export class Track extends Thing {
     },
 
     invalidFieldCombinations: [
+      {message: `Secondary releases never count in artist totals`, fields: [
+        'Main Release',
+        'Count In Artist Totals',
+      ]},
+
       {message: `Secondary releases inherit references from the main one`, fields: [
         'Main Release',
         'Referenced Tracks',
@@ -790,6 +809,10 @@ export class Track extends Thing {
   }
 
   countOwnContributionInContributionTotals(_contrib) {
+    if (!this.countInArtistTotals) {
+      return false;
+    }
+
     if (this.isSecondaryRelease) {
       return false;
     }
@@ -798,6 +821,10 @@ export class Track extends Thing {
   }
 
   countOwnContributionInDurationTotals(_contrib) {
+    if (!this.countInArtistTotals) {
+      return false;
+    }
+
     if (this.isSecondaryRelease) {
       return false;
     }