musora-content-services 1.2.4 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +5 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +11 -0
- package/babel.config.cjs +1 -1
- package/jest.config.js +9 -10
- package/jsdoc.json +17 -12
- package/package.json +2 -1
- package/src/contentMetaData.js +1190 -1131
- package/src/contentTypeConfig.js +492 -387
- package/src/filterBuilder.js +163 -145
- package/src/index.d.ts +227 -237
- package/src/index.js +226 -236
- package/src/services/config.js +12 -12
- package/src/services/contentLikes.js +33 -32
- package/src/services/contentProgress.js +233 -200
- package/src/services/dataContext.js +99 -93
- package/src/services/lastUpdated.js +7 -7
- package/src/services/railcontent.js +368 -364
- package/src/services/sanity.js +975 -955
- package/src/services/userPermissions.js +12 -14
- package/test/contentLikes.test.js +89 -86
- package/test/contentProgress.test.js +229 -236
- package/test/initializeTests.js +54 -51
- package/test/lastUpdated.test.js +20 -18
- package/test/live/contentProgressLive.test.js +135 -137
- package/test/live/railcontentLive.test.js +12 -14
- package/test/localStorageMock.js +16 -16
- package/test/log.js +5 -5
- package/test/sanityQueryService.test.js +857 -821
- package/test/userPermissions.test.js +15 -15
- package/tools/generate-index.cjs +108 -111
- package/.yarnrc.yml +0 -1
package/src/contentTypeConfig.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
//import {AWSUrl, CloudFrontURl} from "./services/config";
|
|
2
|
-
export const AWSUrl = 'https://s3.us-east-1.amazonaws.com/musora-web-platform'
|
|
3
|
-
export const CloudFrontURl = 'https://d3fzm1tzeyr5n3.cloudfront.net'
|
|
2
|
+
export const AWSUrl = 'https://s3.us-east-1.amazonaws.com/musora-web-platform'
|
|
3
|
+
export const CloudFrontURl = 'https://d3fzm1tzeyr5n3.cloudfront.net'
|
|
4
4
|
export const DEFAULT_FIELDS = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]
|
|
5
|
+
"'sanity_id' : _id",
|
|
6
|
+
"'id': railcontent_id",
|
|
7
|
+
'railcontent_id',
|
|
8
|
+
artistOrInstructorName(),
|
|
9
|
+
'artist',
|
|
10
|
+
'title',
|
|
11
|
+
"'image': thumbnail.asset->url",
|
|
12
|
+
"'thumbnail': thumbnail.asset->url",
|
|
13
|
+
'difficulty',
|
|
14
|
+
'difficulty_string',
|
|
15
|
+
'web_url_path',
|
|
16
|
+
"'url': web_url_path",
|
|
17
|
+
'published_on',
|
|
18
|
+
"'type': _type",
|
|
19
|
+
'progress_percent',
|
|
20
|
+
"'length_in_seconds' : coalesce(length_in_seconds, soundslice[0].soundslice_length_in_second)",
|
|
21
|
+
'brand',
|
|
22
|
+
"'genre': genre[]->name",
|
|
23
|
+
'status',
|
|
24
|
+
"'slug' : slug.current",
|
|
25
|
+
"'permission_id': permission[]->railcontent_id",
|
|
26
|
+
'xp',
|
|
27
|
+
'child_count',
|
|
28
|
+
]
|
|
29
29
|
|
|
30
|
-
export const descriptionField = 'description[0].children[0].text'
|
|
30
|
+
export const descriptionField = 'description[0].children[0].text'
|
|
31
31
|
// this pulls both any defined resources for the document as well as any resources in the parent document
|
|
32
32
|
export const resourcesField = `[
|
|
33
33
|
... resource[]{resource_name, _key, "resource_url": coalesce('${CloudFrontURl}'+string::split(resource_aws.asset->fileURL, '${AWSUrl}')[1], resource_url )},
|
|
34
34
|
... *[railcontent_id == ^.parent_content_data[0].id] [0].resource[]{resource_name, _key, "resource_url": coalesce('${CloudFrontURl}'+string::split(resource_aws.asset->fileURL, '${AWSUrl}')[1], resource_url )},
|
|
35
|
-
]
|
|
35
|
+
]`
|
|
36
36
|
|
|
37
37
|
/*
|
|
38
38
|
* NOTE: TP-366 - Arrays can be either arrays of different objects or arrays of different primitives, not both
|
|
@@ -57,88 +57,113 @@ export const assignmentsField = `"assignments":assignment[]{
|
|
|
57
57
|
},`
|
|
58
58
|
|
|
59
59
|
const contentWithInstructorsField = {
|
|
60
|
-
|
|
61
|
-
'"instructors": instructor[]->name',
|
|
62
|
-
]
|
|
60
|
+
fields: ['"instructors": instructor[]->name'],
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
const contentWithSortField = {
|
|
66
|
-
|
|
67
|
-
'sort',
|
|
68
|
-
]
|
|
64
|
+
fields: ['sort'],
|
|
69
65
|
}
|
|
70
66
|
export const showsTypes = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
67
|
+
drumeo: [
|
|
68
|
+
'odd-times',
|
|
69
|
+
'drum-fest-international-2022',
|
|
70
|
+
'spotlight',
|
|
71
|
+
'the-history-of-electronic-drums',
|
|
72
|
+
'backstage-secret',
|
|
73
|
+
'quick-tips',
|
|
74
|
+
'question-and-answer',
|
|
75
|
+
'student-collaboration',
|
|
76
|
+
'live',
|
|
77
|
+
'podcast',
|
|
78
|
+
'solo',
|
|
79
|
+
'boot-camp',
|
|
80
|
+
'gear-guide',
|
|
81
|
+
'performance',
|
|
82
|
+
'in-rhythm',
|
|
83
|
+
'challenges',
|
|
84
|
+
'on-the-road',
|
|
85
|
+
'diy-drum-experiment',
|
|
86
|
+
'rhythmic-adventures-of-captain-carson',
|
|
87
|
+
'study-the-greats',
|
|
88
|
+
'rhythms-from-another-planet',
|
|
89
|
+
'tama',
|
|
90
|
+
'paiste-cymbals',
|
|
91
|
+
'behind-the-scenes',
|
|
92
|
+
'exploring-beats',
|
|
93
|
+
'sonor',
|
|
94
|
+
],
|
|
95
|
+
pianote: ['student-review', 'question-and-answer'],
|
|
96
|
+
guitareo: ['student-review', 'question-and-answer', 'archives', 'recording'],
|
|
97
|
+
singeo: ['student-review', 'question-and-answer'],
|
|
78
98
|
}
|
|
79
99
|
|
|
80
|
-
export const coachLessonsTypes = [
|
|
100
|
+
export const coachLessonsTypes = [
|
|
101
|
+
'course',
|
|
102
|
+
'course-part',
|
|
103
|
+
'coach-stream',
|
|
104
|
+
'student-focus',
|
|
105
|
+
'quick-tips',
|
|
106
|
+
'pack',
|
|
107
|
+
'semester-pack',
|
|
108
|
+
'question-and-answer',
|
|
109
|
+
'song-tutorial',
|
|
110
|
+
'song-tutorial-children',
|
|
111
|
+
'workout',
|
|
112
|
+
]
|
|
81
113
|
|
|
82
114
|
export let contentTypeConfig = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
],
|
|
90
|
-
'relationships': {
|
|
91
|
-
'artist': {
|
|
92
|
-
isOneToOne: true
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
'slug': 'songs',
|
|
115
|
+
song: {
|
|
116
|
+
fields: ['album', 'soundslice', 'instrumentless', `"resources": ${resourcesField}`],
|
|
117
|
+
relationships: {
|
|
118
|
+
artist: {
|
|
119
|
+
isOneToOne: true,
|
|
120
|
+
},
|
|
96
121
|
},
|
|
97
|
-
'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
slug: 'songs',
|
|
123
|
+
},
|
|
124
|
+
'song-tutorial': {
|
|
125
|
+
fields: [
|
|
126
|
+
'"lesson_count": child_count',
|
|
127
|
+
`"lessons": child[]->{
|
|
101
128
|
"id": railcontent_id,
|
|
102
129
|
title,
|
|
103
130
|
"image": thumbnail.asset->url,
|
|
104
131
|
"instructors": instructor[]->name,
|
|
105
132
|
length_in_seconds,
|
|
106
133
|
}`,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
'song-tutorial-children': {
|
|
115
|
-
'fields': [
|
|
116
|
-
`"resources": ${resourcesField}`,
|
|
117
|
-
],
|
|
134
|
+
],
|
|
135
|
+
relationships: {
|
|
136
|
+
artist: {
|
|
137
|
+
isOneToOne: true,
|
|
138
|
+
},
|
|
118
139
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
},
|
|
141
|
+
'song-tutorial-children': {
|
|
142
|
+
fields: [`"resources": ${resourcesField}`],
|
|
143
|
+
},
|
|
144
|
+
challenge: {
|
|
145
|
+
fields: [
|
|
146
|
+
'enrollment_start_time',
|
|
147
|
+
'enrollment_end_time',
|
|
148
|
+
"'registration_url': '/' + brand + '/enrollment/' + slug.current",
|
|
149
|
+
'"lesson_count": child_count',
|
|
150
|
+
'"primary_cta_text": select(dateTime(published_on) > dateTime(now()) && dateTime(enrollment_start_time) > dateTime(now()) => "Notify Me", "Start Challenge")',
|
|
151
|
+
'challenge_state',
|
|
152
|
+
'challenge_state_text',
|
|
153
|
+
`"description": ${descriptionField}`,
|
|
154
|
+
'total_xp',
|
|
155
|
+
'xp',
|
|
156
|
+
'"instructors": instructor[]->name',
|
|
157
|
+
'"instructor_signature": instructor[0]->signature.asset->url',
|
|
158
|
+
'"header_image_url": thumbnail.asset->url',
|
|
159
|
+
'"logo_image_url": logo_image_url.asset->url',
|
|
160
|
+
'"award": award.asset->url',
|
|
161
|
+
'award_custom_text',
|
|
162
|
+
'"gold_award": gold_award.asset->url',
|
|
163
|
+
'"silver_award": silver_award.asset->url',
|
|
164
|
+
'"bronze_award": bronze_award.asset->url',
|
|
165
|
+
'is_solo',
|
|
166
|
+
`"lessons": child[]->{
|
|
142
167
|
"id": railcontent_id,
|
|
143
168
|
title,
|
|
144
169
|
"image": thumbnail.asset->url,
|
|
@@ -150,36 +175,36 @@ export let contentTypeConfig = {
|
|
|
150
175
|
is_always_unlocked_for_challenge,
|
|
151
176
|
is_bonus_content_for_challenge,
|
|
152
177
|
}`,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
course: {
|
|
181
|
+
fields: [
|
|
182
|
+
'"lesson_count": child_count',
|
|
183
|
+
'"instructors": instructor[]->name',
|
|
184
|
+
`"description": ${descriptionField}`,
|
|
185
|
+
`"resource": ${resourcesField}`,
|
|
186
|
+
'xp',
|
|
187
|
+
'total_xp',
|
|
188
|
+
`"lessons": child[]->{
|
|
164
189
|
"id": railcontent_id,
|
|
165
190
|
title,
|
|
166
191
|
"image": thumbnail.asset->url,
|
|
167
192
|
"instructors": instructor[]->name,
|
|
168
193
|
length_in_seconds,
|
|
169
194
|
}`,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
195
|
+
],
|
|
196
|
+
slug: 'courses',
|
|
197
|
+
},
|
|
198
|
+
'parent-download': {
|
|
199
|
+
fields: [
|
|
200
|
+
'"lesson_count": child_count',
|
|
201
|
+
'"instructors": instructor[]->name',
|
|
202
|
+
`"description": ${descriptionField}`,
|
|
203
|
+
`"resource": ${resourcesField}`,
|
|
204
|
+
'xp',
|
|
205
|
+
'total_xp',
|
|
206
|
+
'"thumbnail_url":thumbnail.asset->url',
|
|
207
|
+
`"lessons": child[]->{
|
|
183
208
|
"id": railcontent_id,
|
|
184
209
|
title,
|
|
185
210
|
published_on,
|
|
@@ -212,138 +237,128 @@ export let contentTypeConfig = {
|
|
|
212
237
|
video,
|
|
213
238
|
parent_content_data,
|
|
214
239
|
}`,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
method: {
|
|
243
|
+
fields: [
|
|
244
|
+
`"description": ${descriptionField}`,
|
|
245
|
+
'hide_from_recsys',
|
|
246
|
+
'"image": thumbnail.asset->url',
|
|
247
|
+
'"instructors":instructor[]->name',
|
|
248
|
+
'"lesson_count": child_count',
|
|
249
|
+
'length_in_seconds',
|
|
250
|
+
'permission',
|
|
251
|
+
'popularity',
|
|
252
|
+
'published_on',
|
|
253
|
+
'railcontent_id',
|
|
254
|
+
'"thumbnail_logo": logo_image_url.asset->url',
|
|
255
|
+
'title',
|
|
256
|
+
'total_xp',
|
|
257
|
+
'"type": _type',
|
|
258
|
+
'xp',
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
'learning-path-course': {
|
|
262
|
+
fields: [
|
|
263
|
+
'"lesson_count": child_count',
|
|
264
|
+
'"instructors": instructor[]->name',
|
|
265
|
+
`"description": ${descriptionField}`,
|
|
266
|
+
`"resource": ${resourcesField}`,
|
|
267
|
+
'xp',
|
|
268
|
+
'total_xp',
|
|
269
|
+
`"lessons": child[]->{
|
|
245
270
|
"id": railcontent_id,
|
|
246
271
|
title,
|
|
247
272
|
"image": thumbnail.asset->url,
|
|
248
273
|
"instructors": instructor[]->name,
|
|
249
274
|
length_in_seconds,
|
|
250
275
|
}`,
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
'learning-path-level': {
|
|
279
|
+
fields: [
|
|
280
|
+
'"lesson_count": child_count',
|
|
281
|
+
'"instructors": instructor[]->name',
|
|
282
|
+
`"description": ${descriptionField}`,
|
|
283
|
+
`"resource": ${resourcesField}`,
|
|
284
|
+
'xp',
|
|
285
|
+
'total_xp',
|
|
286
|
+
`"lessons": child[]->{
|
|
262
287
|
"id": railcontent_id,
|
|
263
288
|
title,
|
|
264
289
|
"image": thumbnail.asset->url,
|
|
265
290
|
"instructors": instructor[]->name,
|
|
266
291
|
length_in_seconds,
|
|
267
292
|
}`,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
'total_xp',
|
|
295
|
-
`"children": child[]->{
|
|
293
|
+
],
|
|
294
|
+
},
|
|
295
|
+
workout: {
|
|
296
|
+
fields: [artistOrInstructorNameAsArray()],
|
|
297
|
+
slug: 'workouts',
|
|
298
|
+
},
|
|
299
|
+
'play-along': {
|
|
300
|
+
fields: [
|
|
301
|
+
'"style": genre[]->name',
|
|
302
|
+
'mp3_no_drums_no_click_url',
|
|
303
|
+
'mp3_yes_drums_yes_click_url',
|
|
304
|
+
'mp3_no_drums_yes_click_url',
|
|
305
|
+
'mp3_yes_drums_no_click_url',
|
|
306
|
+
'bpm',
|
|
307
|
+
],
|
|
308
|
+
slug: 'play-alongs',
|
|
309
|
+
},
|
|
310
|
+
pack: {
|
|
311
|
+
fields: [
|
|
312
|
+
'"lesson_count": coalesce(count(child[]->.child[]->), 0)',
|
|
313
|
+
'xp',
|
|
314
|
+
`"description": ${descriptionField}`,
|
|
315
|
+
'"instructors": instructor[]->name',
|
|
316
|
+
'"logo_image_url": logo_image_url.asset->url',
|
|
317
|
+
'total_xp',
|
|
318
|
+
`"children": child[]->{
|
|
296
319
|
"description": ${descriptionField},
|
|
297
320
|
"lesson_count": child_count,
|
|
298
321
|
${getFieldsForContentType()}
|
|
299
322
|
}`,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
'
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
'slug': 'routines',
|
|
320
|
-
},
|
|
321
|
-
'pack-children': {
|
|
322
|
-
'fields': [
|
|
323
|
-
'child_count',
|
|
324
|
-
`"children": child[]->{
|
|
323
|
+
`"resources": ${resourcesField}`,
|
|
324
|
+
'"thumbnail": thumbnail.asset->url',
|
|
325
|
+
'"light_logo": light_mode_logo_url.asset->url',
|
|
326
|
+
'"dark_logo": dark_mode_logo_url.asset->url',
|
|
327
|
+
`"description": ${descriptionField}`,
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
rudiment: {
|
|
331
|
+
fields: ['sheet_music_thumbnail_url'],
|
|
332
|
+
slug: 'rudiments',
|
|
333
|
+
},
|
|
334
|
+
routine: {
|
|
335
|
+
fields: [`"description": ${descriptionField}`, 'high_soundslice_slug', 'low_soundslice_slug'],
|
|
336
|
+
slug: 'routines',
|
|
337
|
+
},
|
|
338
|
+
'pack-children': {
|
|
339
|
+
fields: [
|
|
340
|
+
'child_count',
|
|
341
|
+
`"children": child[]->{
|
|
325
342
|
"description": ${descriptionField},
|
|
326
343
|
${getFieldsForContentType()}
|
|
327
344
|
}`,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
`"instructors":instructor[]->name`,
|
|
346
|
-
`"units": child[]->{
|
|
345
|
+
`"resources": ${resourcesField}`,
|
|
346
|
+
'"image": logo_image_url.asset->url',
|
|
347
|
+
'"thumbnail": thumbnail.asset->url',
|
|
348
|
+
'"light_logo": light_mode_logo_url.asset->url',
|
|
349
|
+
'"dark_logo": dark_mode_logo_url.asset->url',
|
|
350
|
+
`"description": ${descriptionField}`,
|
|
351
|
+
'total_xp',
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
'pack-bundle-lesson': {
|
|
355
|
+
fields: [`"resources": ${resourcesField}`],
|
|
356
|
+
},
|
|
357
|
+
foundation: {
|
|
358
|
+
fields: [
|
|
359
|
+
`"description": ${descriptionField}`,
|
|
360
|
+
`"instructors":instructor[]->name`,
|
|
361
|
+
`"units": child[]->{
|
|
347
362
|
"id": railcontent_id,
|
|
348
363
|
published_on,
|
|
349
364
|
child_count,
|
|
@@ -357,113 +372,192 @@ export let contentTypeConfig = {
|
|
|
357
372
|
xp,
|
|
358
373
|
web_url_path,
|
|
359
374
|
"url": web_url_path,
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
375
|
+
}`,
|
|
376
|
+
],
|
|
377
|
+
},
|
|
378
|
+
unit: {
|
|
379
|
+
fields: [
|
|
380
|
+
'"lesson_count": child_count',
|
|
381
|
+
'"instructors": instructor[]->name',
|
|
382
|
+
`"description": ${descriptionField}`,
|
|
383
|
+
`"resource": ${resourcesField}`,
|
|
384
|
+
'xp',
|
|
385
|
+
'total_xp',
|
|
386
|
+
`"lessons": child[]->{
|
|
372
387
|
"id": railcontent_id,
|
|
373
388
|
title,
|
|
374
389
|
"image": thumbnail.asset->url,
|
|
375
390
|
"instructors": instructor[]->name,
|
|
376
391
|
length_in_seconds,
|
|
377
392
|
}`,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
instructor: {
|
|
396
|
+
fields: [
|
|
397
|
+
'"coach_top_banner_image": coach_top_banner_image.asset->url',
|
|
398
|
+
'"coach_bottom_banner_image": coach_bottom_banner_image.asset->url',
|
|
399
|
+
'"coach_card_image": coach_card_image.asset->url',
|
|
400
|
+
'"coach_featured_image": coach_featured_image.asset->url',
|
|
401
|
+
'"coach_top_banner_image": coach_top_banner_image.asset->url',
|
|
402
|
+
'"focus": focus[]->name',
|
|
403
|
+
'focus_text',
|
|
404
|
+
'forum_thread_id',
|
|
405
|
+
'"long_bio": long_bio[0].children[0].text',
|
|
406
|
+
'name',
|
|
407
|
+
'"short_bio" : short_bio[0].children[0].text',
|
|
408
|
+
'bands',
|
|
409
|
+
'endorsements',
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
// content with just the added 'instructors' Field
|
|
413
|
+
'student-focus': contentWithInstructorsField,
|
|
414
|
+
'quick-tips': contentWithInstructorsField,
|
|
415
|
+
'drum-fest-international-2022': contentWithInstructorsField,
|
|
416
|
+
spotlight: contentWithInstructorsField,
|
|
417
|
+
'the-history-of-electronic-drums': contentWithInstructorsField,
|
|
418
|
+
'backstage-secret': contentWithInstructorsField,
|
|
419
|
+
'question-and-answer': contentWithInstructorsField,
|
|
420
|
+
'student-collaboration': contentWithInstructorsField,
|
|
421
|
+
live: { ...contentWithInstructorsField, slug: 'live-streams' },
|
|
422
|
+
solo: { ...contentWithInstructorsField, slug: 'solos' },
|
|
423
|
+
'boot-camp': contentWithInstructorsField,
|
|
424
|
+
'gear-guids': contentWithInstructorsField,
|
|
425
|
+
performance: contentWithInstructorsField,
|
|
426
|
+
challenges: contentWithInstructorsField,
|
|
427
|
+
'on-the-road': contentWithInstructorsField,
|
|
428
|
+
// content with just the added 'sort' field
|
|
429
|
+
podcast: contentWithSortField,
|
|
430
|
+
'in-rhythm': contentWithSortField,
|
|
431
|
+
'diy-drum-experiment': contentWithSortField,
|
|
432
|
+
'rhythmic-adventures-of-captain-carson': contentWithSortField,
|
|
433
|
+
'study-the-greats': contentWithSortField,
|
|
434
|
+
'rhythms-from-another-planet': contentWithSortField,
|
|
435
|
+
'paiste-cymbals': contentWithInstructorsField,
|
|
436
|
+
'behind-the-scenes': contentWithSortField,
|
|
437
|
+
'exploring-beats': contentWithSortField,
|
|
438
|
+
sonor: contentWithSortField,
|
|
424
439
|
}
|
|
425
440
|
|
|
426
|
-
export const songAccessMembership = 94
|
|
441
|
+
export const songAccessMembership = 94
|
|
427
442
|
|
|
428
443
|
export function getNewReleasesTypes(brand) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
444
|
+
const baseNewTypes = [
|
|
445
|
+
'student-review',
|
|
446
|
+
'student-review',
|
|
447
|
+
'student-focus',
|
|
448
|
+
'coach-stream',
|
|
449
|
+
'live',
|
|
450
|
+
'question-and-answer',
|
|
451
|
+
'boot-camps',
|
|
452
|
+
'quick-tips',
|
|
453
|
+
'workout',
|
|
454
|
+
'challenge',
|
|
455
|
+
'challenge-part',
|
|
456
|
+
'podcasts',
|
|
457
|
+
'pack',
|
|
458
|
+
'song',
|
|
459
|
+
'learning-path-level',
|
|
460
|
+
'play-along',
|
|
461
|
+
'course',
|
|
462
|
+
'unit',
|
|
463
|
+
]
|
|
464
|
+
switch (brand) {
|
|
465
|
+
case 'drumeo':
|
|
466
|
+
return [
|
|
467
|
+
...baseNewTypes,
|
|
468
|
+
'drum-fest-international-2022',
|
|
469
|
+
'spotlight',
|
|
470
|
+
'the-history-of-electronic-drums',
|
|
471
|
+
'backstage-secrets',
|
|
472
|
+
'student-collaborations',
|
|
473
|
+
'live',
|
|
474
|
+
'solos',
|
|
475
|
+
'gear-guides',
|
|
476
|
+
'performances',
|
|
477
|
+
'in-rhythm',
|
|
478
|
+
'challenges',
|
|
479
|
+
'on-the-road',
|
|
480
|
+
'diy-drum-experiments',
|
|
481
|
+
'rhythmic-adventures-of-captain-carson',
|
|
482
|
+
'study-the-greats',
|
|
483
|
+
'rhythms-from-another-planet',
|
|
484
|
+
'tama-drums',
|
|
485
|
+
'paiste-cymbals',
|
|
486
|
+
'behind-the-scenes',
|
|
487
|
+
'exploring-beats',
|
|
488
|
+
'sonor',
|
|
489
|
+
]
|
|
490
|
+
case 'guitareo':
|
|
491
|
+
return [...baseNewTypes, 'archives', 'recording', 'chords-and-scales']
|
|
492
|
+
case 'pianote':
|
|
493
|
+
case 'singeo':
|
|
494
|
+
default:
|
|
495
|
+
return baseNewTypes
|
|
496
|
+
}
|
|
440
497
|
}
|
|
441
498
|
|
|
442
499
|
export function getUpcomingEventsTypes(brand) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
500
|
+
const baseLiveTypes = [
|
|
501
|
+
'student-review',
|
|
502
|
+
'student-review',
|
|
503
|
+
'student-focus',
|
|
504
|
+
'coach-stream',
|
|
505
|
+
'live',
|
|
506
|
+
'question-and-answer',
|
|
507
|
+
'boot-camps',
|
|
508
|
+
'quick-tips',
|
|
509
|
+
'recording',
|
|
510
|
+
'pack-bundle-lesson',
|
|
511
|
+
]
|
|
512
|
+
switch (brand) {
|
|
513
|
+
case 'drumeo':
|
|
514
|
+
return [
|
|
515
|
+
...baseLiveTypes,
|
|
516
|
+
'drum-fest-international-2022',
|
|
517
|
+
'spotlight',
|
|
518
|
+
'the-history-of-electronic-drums',
|
|
519
|
+
'backstage-secrets',
|
|
520
|
+
'student-collaborations',
|
|
521
|
+
'live',
|
|
522
|
+
'podcasts',
|
|
523
|
+
'solos',
|
|
524
|
+
'gear-guides',
|
|
525
|
+
'performances',
|
|
526
|
+
'in-rhythm',
|
|
527
|
+
'challenges',
|
|
528
|
+
'on-the-road',
|
|
529
|
+
'diy-drum-experiments',
|
|
530
|
+
'rhythmic-adventures-of-captain-carson',
|
|
531
|
+
'study-the-greats',
|
|
532
|
+
'rhythms-from-another-planet',
|
|
533
|
+
'tama-drums',
|
|
534
|
+
'paiste-cymbals',
|
|
535
|
+
'behind-the-scenes',
|
|
536
|
+
'exploring-beats',
|
|
537
|
+
'sonor',
|
|
538
|
+
]
|
|
539
|
+
case 'guitareo':
|
|
540
|
+
return [...baseLiveTypes, 'archives']
|
|
541
|
+
case 'pianote':
|
|
542
|
+
case 'singeo':
|
|
543
|
+
default:
|
|
544
|
+
return baseLiveTypes
|
|
545
|
+
}
|
|
454
546
|
}
|
|
455
547
|
|
|
456
548
|
export function artistOrInstructorName(key = 'artist_name') {
|
|
457
|
-
|
|
549
|
+
return `'${key}': coalesce(artist->name, instructor[0]->name)`
|
|
458
550
|
}
|
|
459
551
|
|
|
460
552
|
export function artistOrInstructorNameAsArray(key = 'artists') {
|
|
461
|
-
|
|
553
|
+
return `'${key}': select(artist->name != null => [artist->name], instructor[]->name)`
|
|
462
554
|
}
|
|
463
555
|
|
|
464
556
|
export function getFieldsForContentType(contentType, asQueryString = true) {
|
|
465
|
-
|
|
466
|
-
|
|
557
|
+
const fields = contentType
|
|
558
|
+
? DEFAULT_FIELDS.concat(contentTypeConfig?.[contentType]?.fields ?? [])
|
|
559
|
+
: DEFAULT_FIELDS
|
|
560
|
+
return asQueryString ? fields.toString() + ',' : fields
|
|
467
561
|
}
|
|
468
562
|
|
|
469
563
|
/**
|
|
@@ -473,86 +567,97 @@ export function getFieldsForContentType(contentType, asQueryString = true) {
|
|
|
473
567
|
* @returns {string} - A string that can be used in a groq query
|
|
474
568
|
*/
|
|
475
569
|
export function filtersToGroq(filters, selectedFilters = []) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
570
|
+
if (!filters) {
|
|
571
|
+
filters = []
|
|
572
|
+
}
|
|
479
573
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
574
|
+
//Account for multiple railcontent id's
|
|
575
|
+
let multipleIdFilters = ''
|
|
576
|
+
filters.forEach((item) => {
|
|
577
|
+
if (item.includes('railcontent_id in')) {
|
|
578
|
+
filters.pop(item)
|
|
579
|
+
multipleIdFilters += ` && ${item} `
|
|
580
|
+
}
|
|
581
|
+
})
|
|
488
582
|
|
|
489
|
-
|
|
490
|
-
|
|
583
|
+
//Group All Other filters
|
|
584
|
+
const groupedFilters = groupFilters(filters)
|
|
491
585
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
} else if (
|
|
525
|
-
|
|
526
|
-
} else
|
|
527
|
-
|
|
528
|
-
const [min, max] = value.split('-').map(Number);
|
|
529
|
-
return `(${key} > ${min} && ${key} < ${max})`;
|
|
530
|
-
} else if (value.includes('+')) {
|
|
531
|
-
const min = parseInt(value, 10);
|
|
532
|
-
return `(${key} > ${min})`;
|
|
533
|
-
} else {
|
|
534
|
-
return `${key} == ${value}`;
|
|
535
|
-
}
|
|
536
|
-
} else if (!selectedFilters.includes(key)) {
|
|
537
|
-
return ` ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`;
|
|
586
|
+
//Format groupFilter itemsss
|
|
587
|
+
const filterClauses = Object.entries(groupedFilters)
|
|
588
|
+
.map(([key, values]) => {
|
|
589
|
+
if (!key || values.length === 0) return ''
|
|
590
|
+
if (key.startsWith('is_')) {
|
|
591
|
+
return `&& ${key} == true`
|
|
592
|
+
}
|
|
593
|
+
// Filter out values that exist in selectedFilters
|
|
594
|
+
const joinedValues = values
|
|
595
|
+
.map((value) => {
|
|
596
|
+
if (key === 'bpm' && !selectedFilters.includes('bpm')) {
|
|
597
|
+
if (value.includes('-')) {
|
|
598
|
+
const [min, max] = value.split('-').map(Number)
|
|
599
|
+
return `(bpm > ${min} && bpm < ${max})`
|
|
600
|
+
} else if (value.includes('+')) {
|
|
601
|
+
const min = parseInt(value, 10)
|
|
602
|
+
return `(bpm > ${min})`
|
|
603
|
+
} else {
|
|
604
|
+
return `bpm == ${value}`
|
|
605
|
+
}
|
|
606
|
+
} else if (
|
|
607
|
+
['creativity', 'essential', 'focus', 'genre', 'lifestyle', 'theory', 'topic'].includes(
|
|
608
|
+
key
|
|
609
|
+
) &&
|
|
610
|
+
!selectedFilters.includes(key)
|
|
611
|
+
) {
|
|
612
|
+
return `"${value}" in ${key}[]->name`
|
|
613
|
+
} else if (key === 'gear' && !selectedFilters.includes('gear')) {
|
|
614
|
+
return `gear match "${value}"`
|
|
615
|
+
} else if (key === 'instrumentless' && !selectedFilters.includes(key)) {
|
|
616
|
+
if (value === 'Full Song Only') {
|
|
617
|
+
return `(!instrumentless || instrumentless == null)`
|
|
618
|
+
} else if (value === 'Instrument Removed') {
|
|
619
|
+
return `instrumentless`
|
|
620
|
+
} else {
|
|
621
|
+
return `instrumentless == ${value}`
|
|
538
622
|
}
|
|
539
|
-
|
|
623
|
+
} else if (key === 'difficulty' && !selectedFilters.includes(key)) {
|
|
624
|
+
return `difficulty_string == "${value}"`
|
|
625
|
+
} else if (key === 'type' && !selectedFilters.includes(key)) {
|
|
626
|
+
return `_type == "${value}"`
|
|
627
|
+
} else if (key === 'length_in_seconds') {
|
|
628
|
+
if (value.includes('-')) {
|
|
629
|
+
const [min, max] = value.split('-').map(Number)
|
|
630
|
+
return `(${key} > ${min} && ${key} < ${max})`
|
|
631
|
+
} else if (value.includes('+')) {
|
|
632
|
+
const min = parseInt(value, 10)
|
|
633
|
+
return `(${key} > ${min})`
|
|
634
|
+
} else {
|
|
635
|
+
return `${key} == ${value}`
|
|
636
|
+
}
|
|
637
|
+
} else if (!selectedFilters.includes(key)) {
|
|
638
|
+
return ` ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`
|
|
639
|
+
}
|
|
640
|
+
})
|
|
641
|
+
.filter(Boolean)
|
|
642
|
+
.join(' || ')
|
|
540
643
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
})
|
|
644
|
+
// Return the constructed filter clause
|
|
645
|
+
return joinedValues.length > 0 ? `&& (${joinedValues})` : ''
|
|
646
|
+
})
|
|
647
|
+
.filter(Boolean)
|
|
648
|
+
.join(' ')
|
|
544
649
|
|
|
545
|
-
|
|
546
|
-
|
|
650
|
+
//Return
|
|
651
|
+
return `${multipleIdFilters} ${filterClauses}`
|
|
547
652
|
}
|
|
548
653
|
|
|
549
654
|
function groupFilters(filters) {
|
|
550
|
-
|
|
655
|
+
if (filters.length === 0) return {}
|
|
551
656
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
657
|
+
return filters.reduce((acc, filter) => {
|
|
658
|
+
const [category, value] = filter.split(',')
|
|
659
|
+
if (!acc[category]) acc[category] = []
|
|
660
|
+
acc[category].push(value)
|
|
661
|
+
return acc
|
|
662
|
+
}, {})
|
|
558
663
|
}
|