1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
import {accumulateSum, stitchArrays} from '../../util/sugar.js';
import {
chunkByProperties,
sortAlbumsTracksChronologically,
sortEntryThingPairs,
} from '../../util/wiki-data.js';
export default {
contentDependencies: [
'generateArtistInfoPageChunk',
'generateArtistInfoPageChunkItem',
'generateArtistInfoPageOtherArtistLinks',
'linkAlbum',
'linkTrack',
],
extraDependencies: ['html', 'language'],
query(artist) {
const entries = [
...artist.tracksAsArtist.map(track => ({
thing: track,
entry: {
track,
album: track.album,
date: track.date,
contribs: track.artistContribs,
},
})),
...artist.tracksAsContributor.map(track => ({
thing: track,
entry: {
track,
date: track.date,
album: track.album,
contribs: track.contributorContribs,
},
})),
];
sortEntryThingPairs(entries, sortAlbumsTracksChronologically);
const chunks =
chunkByProperties(
entries.map(({entry}) => entry),
['album', 'date']);
return {chunks};
},
relations(relation, query, artist) {
return {
chunks:
query.chunks.map(() => relation('generateArtistInfoPageChunk')),
albumLinks:
query.chunks.map(({album}) => relation('linkAlbum', album)),
items:
query.chunks.map(({chunk}) =>
chunk.map(() => relation('generateArtistInfoPageChunkItem'))),
trackLinks:
query.chunks.map(({chunk}) =>
chunk.map(({track}) => relation('linkTrack', track))),
trackOtherArtistLinks:
query.chunks.map(({chunk}) =>
chunk.map(({contribs}) => relation('generateArtistInfoPageOtherArtistLinks', contribs, artist))),
};
},
data(query, artist) {
return {
chunkDates:
query.chunks.map(({date}) => date),
chunkDurations:
query.chunks.map(({chunk}) =>
accumulateSum(
chunk
.filter(({track}) => track.duration && track.originalReleaseTrack === null)
.map(({track}) => track.duration))),
chunkDurationsApproximate:
query.chunks.map(({chunk}) =>
chunk
.filter(({track}) => track.duration && track.originalReleaseTrack === null)
.length > 1),
trackDurations:
query.chunks.map(({chunk}) =>
chunk.map(({track}) => track.duration)),
trackContributions:
query.chunks.map(({chunk}) =>
chunk.map(({contribs}) =>
contribs
.find(({who}) => who === artist)
.what)),
trackRereleases:
query.chunks.map(({chunk}) =>
chunk.map(({track}) => track.originalReleaseTrack !== null)),
};
},
generate(data, relations, {html, language}) {
return html.tag('dl',
stitchArrays({
chunk: relations.chunks,
albumLink: relations.albumLinks,
date: data.chunkDates,
duration: data.chunkDurations,
durationApproximate: data.chunkDurationsApproximate,
items: relations.items,
trackLinks: relations.trackLinks,
trackOtherArtistLinks: relations.trackOtherArtistLinks,
trackDurations: data.trackDurations,
trackContributions: data.trackContributions,
trackRereleases: data.trackRereleases,
}).map(({
chunk,
albumLink,
date,
duration,
durationApproximate,
items,
trackLinks,
trackOtherArtistLinks,
trackDurations,
trackContributions,
trackRereleases,
}) =>
chunk.slots({
albumLink,
date,
duration,
durationApproximate,
items:
stitchArrays({
item: items,
trackLink: trackLinks,
otherArtistLinks: trackOtherArtistLinks,
duration: trackDurations,
contribution: trackContributions,
rerelease: trackRereleases,
}).map(({
item,
trackLink,
otherArtistLinks,
duration,
contribution,
rerelease,
}) =>
item.slots({
otherArtistLinks,
contribution,
rerelease,
content:
(duration
? language.$('artistPage.creditList.entry.track.withDuration', {
track: trackLink,
duration: language.formatDuration(duration),
})
: language.$('artistPage.creditList.entry.track', {
track: trackLink,
})),
})),
})));
},
};
|