musora-content-services 1.0.220 → 1.0.222
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +31 -23
- package/src/services/sanity.js +7 -6
- package/test/sanityQueryService.test.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.222](https://github.com/railroadmedia/musora-content-services/compare/v1.0.221...v1.0.222) (2024-12-06)
|
|
6
|
+
|
|
7
|
+
### [1.0.221](https://github.com/railroadmedia/musora-content-services/compare/v1.0.220...v1.0.221) (2024-12-06)
|
|
8
|
+
|
|
5
9
|
### [1.0.220](https://github.com/railroadmedia/musora-content-services/compare/v1.0.219...v1.0.220) (2024-12-06)
|
|
6
10
|
|
|
7
11
|
### [1.0.219](https://github.com/railroadmedia/musora-content-services/compare/v1.0.218...v1.0.219) (2024-12-05)
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -46,8 +46,8 @@ const contentWithSortField = {
|
|
|
46
46
|
]
|
|
47
47
|
}
|
|
48
48
|
const showsTypes = {
|
|
49
|
-
'drumeo': ['odd-times','drum-fest-international-2022', 'spotlight', 'the-history-of-electronic-drums', 'backstage-secret', 'quick-tips', 'question-and-answer', 'student-collaboration',
|
|
50
|
-
|
|
49
|
+
'drumeo': ['odd-times', 'drum-fest-international-2022', 'spotlight', 'the-history-of-electronic-drums', 'backstage-secret', 'quick-tips', 'question-and-answer', 'student-collaboration',
|
|
50
|
+
'live', 'podcast', 'solo', 'boot-camp', 'gear-guide', 'performance', 'in-rhythm', 'challenges', 'on-the-road', 'diy-drum-experiment', 'rhythmic-adventures-of-captain-carson',
|
|
51
51
|
'study-the-greats', 'rhythms-from-another-planet', 'tama', 'paiste-cymbals', 'behind-the-scenes', 'exploring-beats', 'sonor'
|
|
52
52
|
],
|
|
53
53
|
'pianote': ['student-review', 'question-and-answer'],
|
|
@@ -70,7 +70,7 @@ let contentTypeConfig = {
|
|
|
70
70
|
isOneToOne: true
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
'slug':'songs',
|
|
73
|
+
'slug': 'songs',
|
|
74
74
|
},
|
|
75
75
|
'song-tutorial': {
|
|
76
76
|
'fields': [
|
|
@@ -89,7 +89,7 @@ let contentTypeConfig = {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
|
-
'challenge':{
|
|
92
|
+
'challenge': {
|
|
93
93
|
'fields': [
|
|
94
94
|
'enrollment_start_time',
|
|
95
95
|
'enrollment_end_time',
|
|
@@ -141,7 +141,7 @@ let contentTypeConfig = {
|
|
|
141
141
|
length_in_seconds,
|
|
142
142
|
}`,
|
|
143
143
|
],
|
|
144
|
-
'slug':'courses',
|
|
144
|
+
'slug': 'courses',
|
|
145
145
|
},
|
|
146
146
|
'parent-download': {
|
|
147
147
|
'fields': [
|
|
@@ -244,7 +244,7 @@ let contentTypeConfig = {
|
|
|
244
244
|
'fields': [
|
|
245
245
|
artistOrInstructorNameAsArray(),
|
|
246
246
|
],
|
|
247
|
-
'slug':'workouts',
|
|
247
|
+
'slug': 'workouts',
|
|
248
248
|
},
|
|
249
249
|
'play-along': {
|
|
250
250
|
'fields': [
|
|
@@ -255,7 +255,7 @@ let contentTypeConfig = {
|
|
|
255
255
|
'mp3_yes_drums_no_click_url',
|
|
256
256
|
'bpm',
|
|
257
257
|
],
|
|
258
|
-
'slug':'play-alongs',
|
|
258
|
+
'slug': 'play-alongs',
|
|
259
259
|
},
|
|
260
260
|
'pack': {
|
|
261
261
|
'fields': [
|
|
@@ -281,15 +281,15 @@ let contentTypeConfig = {
|
|
|
281
281
|
'fields': [
|
|
282
282
|
'sheet_music_thumbnail_url',
|
|
283
283
|
],
|
|
284
|
-
'slug':'rudiments',
|
|
284
|
+
'slug': 'rudiments',
|
|
285
285
|
},
|
|
286
|
-
'routine':{
|
|
286
|
+
'routine': {
|
|
287
287
|
'fields': [
|
|
288
288
|
`"description": ${descriptionField}`,
|
|
289
289
|
'high_soundslice_slug',
|
|
290
290
|
'low_soundslice_slug'
|
|
291
291
|
],
|
|
292
|
-
'slug':'routines',
|
|
292
|
+
'slug': 'routines',
|
|
293
293
|
},
|
|
294
294
|
'pack-children': {
|
|
295
295
|
'fields': [
|
|
@@ -369,8 +369,8 @@ let contentTypeConfig = {
|
|
|
369
369
|
'backstage-secret': contentWithInstructorsField,
|
|
370
370
|
'question-and-answer': contentWithInstructorsField,
|
|
371
371
|
'student-collaboration': contentWithInstructorsField,
|
|
372
|
-
'live': {
|
|
373
|
-
'solo': {
|
|
372
|
+
'live': {...contentWithInstructorsField, 'slug': 'live-streams'},
|
|
373
|
+
'solo': {...contentWithInstructorsField, 'slug': 'solos'},
|
|
374
374
|
'boot-camp': contentWithInstructorsField,
|
|
375
375
|
'gear-guids': contentWithInstructorsField,
|
|
376
376
|
'performance': contentWithInstructorsField,
|
|
@@ -391,22 +391,22 @@ let contentTypeConfig = {
|
|
|
391
391
|
|
|
392
392
|
function getNewReleasesTypes(brand) {
|
|
393
393
|
const baseNewTypes = ["student-review", "student-review", "student-focus", "coach-stream", "live", "question-and-answer", "boot-camps", "quick-tips", "workout", "challenge", "challenge-part", "podcasts", "pack", "song", "learning-path-level", "play-along", "course", "unit"];
|
|
394
|
-
switch(brand) {
|
|
394
|
+
switch (brand) {
|
|
395
395
|
case 'drumeo':
|
|
396
396
|
return [...baseNewTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "student-collaborations", "live", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor"];
|
|
397
|
-
case 'guitareo':
|
|
397
|
+
case 'guitareo':
|
|
398
398
|
return [...baseNewTypes, "archives", "recording", "chords-and-scales"];
|
|
399
|
-
case 'pianote':
|
|
399
|
+
case 'pianote':
|
|
400
400
|
case 'singeo':
|
|
401
401
|
default:
|
|
402
402
|
return baseNewTypes
|
|
403
|
-
|
|
403
|
+
}
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
function getUpcomingEventsTypes(brand) {
|
|
407
407
|
const baseLiveTypes = ["student-review", "student-review", "student-focus", "coach-stream", "live", "question-and-answer", "boot-camps", "quick-tips", "recording", "pack-bundle-lesson"];
|
|
408
|
-
switch(brand) {
|
|
409
|
-
case 'drumeo':
|
|
408
|
+
switch (brand) {
|
|
409
|
+
case 'drumeo':
|
|
410
410
|
return [...baseLiveTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "student-collaborations", "live", "podcasts", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor"];
|
|
411
411
|
case 'guitareo':
|
|
412
412
|
return [...baseLiveTypes, "archives"];
|
|
@@ -414,21 +414,22 @@ function getUpcomingEventsTypes(brand) {
|
|
|
414
414
|
case 'singeo':
|
|
415
415
|
default:
|
|
416
416
|
return baseLiveTypes;
|
|
417
|
-
|
|
417
|
+
}
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
function artistOrInstructorName(key='artist_name') {
|
|
420
|
+
function artistOrInstructorName(key = 'artist_name') {
|
|
421
421
|
return `'${key}': coalesce(artist->name, instructor[0]->name)`;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
function artistOrInstructorNameAsArray(key='artists') {
|
|
424
|
+
function artistOrInstructorNameAsArray(key = 'artists') {
|
|
425
425
|
return `'${key}': select(artist->name != null => [artist->name], instructor[]->name)`;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
function getFieldsForContentType(contentType, asQueryString=true) {
|
|
428
|
+
function getFieldsForContentType(contentType, asQueryString = true) {
|
|
429
429
|
const fields = contentType ? DEFAULT_FIELDS.concat(contentTypeConfig?.[contentType]?.fields ?? []) : DEFAULT_FIELDS;
|
|
430
430
|
return asQueryString ? fields.toString() + ',' : fields;
|
|
431
431
|
}
|
|
432
|
+
|
|
432
433
|
/**
|
|
433
434
|
* Takes the included fields array and returns a string that can be used in a groq query.
|
|
434
435
|
* @param {Array<string>} filters - An array of strings that represent applied filters. This should be in the format of a key,value array. eg. ['difficulty,Intermediate',
|
|
@@ -459,7 +460,13 @@ function filtersToGroq(filters, selectedFilters = []) {
|
|
|
459
460
|
} else if (key === 'gear' && !selectedFilters.includes('gear')) {
|
|
460
461
|
return `gear match "${value}"`;
|
|
461
462
|
} else if (key === 'instrumentless' && !selectedFilters.includes(key)) {
|
|
462
|
-
|
|
463
|
+
if (value === "Full Song Only") {
|
|
464
|
+
return `(!instrumentless || instrumentless != null)`;
|
|
465
|
+
} else if (value === "Instrument Removed") {
|
|
466
|
+
return `instrumentless`;
|
|
467
|
+
} else {
|
|
468
|
+
return `instrumentless == ${value}`;
|
|
469
|
+
}
|
|
463
470
|
} else if (key === 'difficulty' && !selectedFilters.includes(key)) {
|
|
464
471
|
return `difficulty_string == "${value}"`;
|
|
465
472
|
} else if (key === 'type' && !selectedFilters.includes(key)) {
|
|
@@ -485,6 +492,7 @@ function filtersToGroq(filters, selectedFilters = []) {
|
|
|
485
492
|
|
|
486
493
|
return filterClauses;
|
|
487
494
|
}
|
|
495
|
+
|
|
488
496
|
function groupFilters(filters) {
|
|
489
497
|
if (filters.length === 0) return {};
|
|
490
498
|
|
package/src/services/sanity.js
CHANGED
|
@@ -831,9 +831,12 @@ export async function fetchAllFilterOptions(
|
|
|
831
831
|
|
|
832
832
|
const constructCommonFilter = (excludeFilter) => {
|
|
833
833
|
const filterWithoutOption = excludeFilter ? filtersToGroq(filters, excludeFilter) : includedFieldsFilter;
|
|
834
|
+
const statusFilter = ' && status == "published"';
|
|
835
|
+
const includeStatusFilter = !['instructor','artist','genre'].includes(contentType);
|
|
836
|
+
|
|
834
837
|
return coachId
|
|
835
|
-
? `brand == '${brand}' && references(*[_type=='instructor' && railcontent_id == ${coachId}]._id) ${filterWithoutOption || ''}`
|
|
836
|
-
: `_type == '${contentType}' && brand == "${brand}"${style && excludeFilter !== "style" ? ` && '${style}' in genre[]->name` : ''}${artist && excludeFilter !== "artist" ? ` && artist->name == '${artist}'` : ''} ${progressFilter} ${filterWithoutOption || ''}`;
|
|
838
|
+
? `brand == '${brand}' && status == "published" && references(*[_type=='instructor' && railcontent_id == ${coachId}]._id) ${filterWithoutOption || ''}`
|
|
839
|
+
: `_type == '${contentType}' && brand == "${brand}"${includeStatusFilter ? statusFilter : ''}${style && excludeFilter !== "style" ? ` && '${style}' in genre[]->name` : ''}${artist && excludeFilter !== "artist" ? ` && artist->name == '${artist}'` : ''} ${progressFilter} ${filterWithoutOption || ''}`;
|
|
837
840
|
};
|
|
838
841
|
|
|
839
842
|
const metaData = processMetadata(brand, contentType, true);
|
|
@@ -2018,10 +2021,8 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
|
|
|
2018
2021
|
][count > 0],`;
|
|
2019
2022
|
break;
|
|
2020
2023
|
case "type":
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
}).join(', ');
|
|
2024
|
-
filterGroq = `"type": [${dynamicTypeOptions}][count > 0],`;
|
|
2024
|
+
const typesString = types.map(t => {return `{"type": "${t}"}`}).join(', ');
|
|
2025
|
+
filterGroq = `"type": [${typesString}]{type, 'count': count(*[_type == ^.type && ${commonFilter}])}[count > 0],`;
|
|
2025
2026
|
break;
|
|
2026
2027
|
case "genre":
|
|
2027
2028
|
case "essential":
|
|
@@ -420,7 +420,7 @@ describe('Sanity Queries', function () {
|
|
|
420
420
|
});
|
|
421
421
|
|
|
422
422
|
test('fetchAllFilterOptions-WithProgress', async () => {
|
|
423
|
-
const ids = [410213,
|
|
423
|
+
const ids = [410213, 413851];
|
|
424
424
|
let response = await fetchAllFilterOptions('drumeo', '', '', '', 'song', '', ids);
|
|
425
425
|
expect(response.meta.totalResults).toBe(2);
|
|
426
426
|
// change the brand and we expect no results
|