musora-content-services 1.0.68 → 1.0.69
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 +2 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +163 -1
- package/src/index.js +2 -0
- package/src/services/sanity.js +25 -15
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.69](https://github.com/railroadmedia/musora-content-services/compare/v1.0.68...v1.0.69) (2024-08-27)
|
|
6
|
+
|
|
5
7
|
### [1.0.68](https://github.com/railroadmedia/musora-content-services/compare/v1.0.67...v1.0.68) (2024-08-27)
|
|
6
8
|
|
|
7
9
|
### [1.0.67](https://github.com/railroadmedia/musora-content-services/compare/v1.0.66...v1.0.67) (2024-08-27)
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -62,7 +62,8 @@ let contentTypeConfig = {
|
|
|
62
62
|
},
|
|
63
63
|
'student-focus': {
|
|
64
64
|
'fields': [
|
|
65
|
-
'
|
|
65
|
+
'length_in_seconds',
|
|
66
|
+
'"instructors": instructor[]->name'
|
|
66
67
|
]
|
|
67
68
|
},
|
|
68
69
|
'method': {
|
|
@@ -84,6 +85,166 @@ let contentTypeConfig = {
|
|
|
84
85
|
'"url": web_url_path',
|
|
85
86
|
'xp',
|
|
86
87
|
]
|
|
88
|
+
},
|
|
89
|
+
'quick-tips': {
|
|
90
|
+
'fields': [
|
|
91
|
+
'length_in_seconds',
|
|
92
|
+
'"instructors": instructor[]->name'
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
'rudiment': {
|
|
96
|
+
'fields': [
|
|
97
|
+
'sheet_music_thumbnail_url',
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
'drum-fest-international-aa2022': {
|
|
101
|
+
'fields': [
|
|
102
|
+
'length_in_seconds',
|
|
103
|
+
'"instructors": instructor[]->name'
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
'spotlight': {
|
|
107
|
+
'fields': [
|
|
108
|
+
'length_in_seconds',
|
|
109
|
+
'"instructors": instructor[]->name'
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
'the-history-of-electronic-drums': {
|
|
113
|
+
'fields': [
|
|
114
|
+
'length_in_seconds',
|
|
115
|
+
'"instructors": instructor[]->name'
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
'backstage-secrets': {
|
|
119
|
+
'fields': [
|
|
120
|
+
'length_in_seconds',
|
|
121
|
+
'"instructors": instructor[]->name'
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
'question-and-answer': {
|
|
125
|
+
'fields': [
|
|
126
|
+
'length_in_seconds',
|
|
127
|
+
'"instructors": instructor[]->name'
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
'student-collaborations': {
|
|
131
|
+
'fields': [
|
|
132
|
+
'length_in_seconds',
|
|
133
|
+
'"instructors": instructor[]->name'
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
'live': {
|
|
137
|
+
'fields': [
|
|
138
|
+
'length_in_seconds',
|
|
139
|
+
'"instructors": instructor[]->name'
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
'podcasts': {
|
|
143
|
+
'fields': [
|
|
144
|
+
'sort',
|
|
145
|
+
'length_in_seconds',
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
'solos': {
|
|
149
|
+
'fields': [
|
|
150
|
+
'length_in_seconds',
|
|
151
|
+
'"instructors": instructor[]->name'
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
'boot-camps': {
|
|
155
|
+
'fields': [
|
|
156
|
+
'length_in_seconds',
|
|
157
|
+
'"instructors": instructor[]->name'
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
'gear-guids': {
|
|
161
|
+
'fields': [
|
|
162
|
+
'length_in_seconds',
|
|
163
|
+
'"instructors": instructor[]->name'
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
'performances': {
|
|
167
|
+
'fields': [
|
|
168
|
+
'length_in_seconds',
|
|
169
|
+
'"instructors": instructor[]->name'
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
'in-rhythm': {
|
|
173
|
+
'fields': [
|
|
174
|
+
'sort',
|
|
175
|
+
'length_in_seconds',
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
'challenges': {
|
|
179
|
+
'fields': [
|
|
180
|
+
'length_in_seconds',
|
|
181
|
+
'"instructors": instructor[]->name'
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
'on-the-road': {
|
|
185
|
+
'fields': [
|
|
186
|
+
'length_in_seconds',
|
|
187
|
+
'"instructors": instructor[]->name'
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
'diy-drum-experiments': {
|
|
191
|
+
'fields': [
|
|
192
|
+
'sort',
|
|
193
|
+
'length_in_seconds',
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
'rhythmic-adventures-of-captain-carson': {
|
|
197
|
+
'fields': [
|
|
198
|
+
'sort',
|
|
199
|
+
'length_in_seconds',
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
'study-the-greats': {
|
|
203
|
+
'fields': [
|
|
204
|
+
'sort',
|
|
205
|
+
'length_in_seconds',
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
'rhythms-from-another-planet': {
|
|
209
|
+
'fields': [
|
|
210
|
+
'sort',
|
|
211
|
+
'length_in_seconds',
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
'paiste-cymbals': {
|
|
215
|
+
'fields': [
|
|
216
|
+
'length_in_seconds',
|
|
217
|
+
'"instructors": instructor[]->name'
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
'behind-the-scenes': {
|
|
221
|
+
'fields': [
|
|
222
|
+
'sort',
|
|
223
|
+
'length_in_seconds',
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
'exploring-beats': {
|
|
227
|
+
'fields': [
|
|
228
|
+
'sort',
|
|
229
|
+
'length_in_seconds',
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
'play-along': {
|
|
233
|
+
'fields': [
|
|
234
|
+
'"style": genre[]->name',
|
|
235
|
+
'mp3_no_drums_no_click_url',
|
|
236
|
+
'mp3_yes_drums_yes_click_url',
|
|
237
|
+
'mp3_no_drums_yes_click_url',
|
|
238
|
+
'mp3_yes_drums_no_click_url',
|
|
239
|
+
'bpm',
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
'pack': {
|
|
243
|
+
'fields': [
|
|
244
|
+
'"lesson_count": child_count',
|
|
245
|
+
'xp',
|
|
246
|
+
`"description": ${descriptionField}`,
|
|
247
|
+
],
|
|
87
248
|
}
|
|
88
249
|
}
|
|
89
250
|
|
|
@@ -96,6 +257,7 @@ function artistOrInstructorNameAsArray(key='artists') {
|
|
|
96
257
|
}
|
|
97
258
|
|
|
98
259
|
function getFieldsForContentType(contentType, asQueryString=true) {
|
|
260
|
+
console.log('this was called, ', contentType)
|
|
99
261
|
const fields = contentType ? DEFAULT_FIELDS.concat(contentTypeConfig?.[contentType]?.fields ?? []) : DEFAULT_FIELDS;
|
|
100
262
|
return asQueryString ? fields.toString() + ',' : fields;
|
|
101
263
|
}
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
fetchMethodNextLesson,
|
|
19
19
|
fetchMethod,
|
|
20
20
|
fetchMethods,
|
|
21
|
+
fetchMethodChildren,
|
|
21
22
|
fetchMethodChildrenIds,
|
|
22
23
|
fetchNextPreviousLesson,
|
|
23
24
|
fetchRelatedLessons,
|
|
@@ -55,6 +56,7 @@ export {
|
|
|
55
56
|
fetchAllFilterOptions,
|
|
56
57
|
fetchMethods,
|
|
57
58
|
fetchMethod,
|
|
59
|
+
fetchMethodChildren,
|
|
58
60
|
fetchMethodNextLesson,
|
|
59
61
|
fetchMethodChildrenIds,
|
|
60
62
|
fetchNextPreviousLesson,
|
package/src/services/sanity.js
CHANGED
|
@@ -397,7 +397,9 @@ export async function fetchAll(brand, type, {
|
|
|
397
397
|
|
|
398
398
|
// Construct the search filter
|
|
399
399
|
const searchFilter = searchTerm
|
|
400
|
-
?
|
|
400
|
+
? groupBy !== "" ?
|
|
401
|
+
`&& (^.name match "${searchTerm}*" || title match "${searchTerm}*")`
|
|
402
|
+
: `&& (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*")`
|
|
401
403
|
: "";
|
|
402
404
|
|
|
403
405
|
// Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
|
|
@@ -422,15 +424,15 @@ export async function fetchAll(brand, type, {
|
|
|
422
424
|
if (groupBy !== "" && isGroupByOneToOne) {
|
|
423
425
|
query = `
|
|
424
426
|
{
|
|
425
|
-
"total": count(*[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ]._id) > 0]),
|
|
426
|
-
"entity": *[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ]._id) > 0]
|
|
427
|
+
"total": count(*[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter}]._id) > 0]),
|
|
428
|
+
"entity": *[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter}]._id) > 0]
|
|
427
429
|
{
|
|
428
430
|
'id': _id,
|
|
429
431
|
'type': _type,
|
|
430
432
|
name,
|
|
431
433
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
432
|
-
'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ]._id),
|
|
433
|
-
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ]{
|
|
434
|
+
'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter}]._id),
|
|
435
|
+
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter}]{
|
|
434
436
|
${fieldsString},
|
|
435
437
|
${groupBy}
|
|
436
438
|
}[0...10]
|
|
@@ -441,15 +443,15 @@ export async function fetchAll(brand, type, {
|
|
|
441
443
|
} else if (groupBy !== "") {
|
|
442
444
|
query = `
|
|
443
445
|
{
|
|
444
|
-
"total": count(*[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref]._id)>0]),
|
|
445
|
-
"entity": *[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref]._id) > 0]
|
|
446
|
+
"total": count(*[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter}]._id) > 0]),
|
|
447
|
+
"entity": *[_type == '${groupBy}' && count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter}]._id) > 0]
|
|
446
448
|
{
|
|
447
449
|
'id': _id,
|
|
448
450
|
'type': _type,
|
|
449
451
|
name,
|
|
450
452
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
451
|
-
'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ]._id),
|
|
452
|
-
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ]{
|
|
453
|
+
'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter}]._id),
|
|
454
|
+
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter}]{
|
|
453
455
|
${fieldsString},
|
|
454
456
|
${groupBy}
|
|
455
457
|
}[0...10]
|
|
@@ -562,12 +564,13 @@ export async function fetchAllFilterOptions(
|
|
|
562
564
|
/**
|
|
563
565
|
* Fetch children content by Railcontent ID.
|
|
564
566
|
* @param {string} railcontentId - The Railcontent ID of the parent content.
|
|
567
|
+
* @param {string} [contentType] - The content type the IDs to add needed fields to the response.
|
|
565
568
|
* @returns {Promise<Array<Object>|null>} - The fetched children content data or [] if not found.
|
|
566
569
|
*/
|
|
567
|
-
export async function fetchChildren(railcontentId) {
|
|
570
|
+
export async function fetchChildren(railcontentId, contentType) {
|
|
568
571
|
const query = `*[railcontent_id == ${railcontentId}]{
|
|
569
572
|
'children': child[]->{
|
|
570
|
-
${getFieldsForContentType()}
|
|
573
|
+
${getFieldsForContentType(contentType)}
|
|
571
574
|
},
|
|
572
575
|
}[0..1]`;
|
|
573
576
|
let parent = await fetchSanity(query, true);
|
|
@@ -600,8 +603,8 @@ export async function fetchMethods(brand) {
|
|
|
600
603
|
//TODOS
|
|
601
604
|
//ADD INSTRUCTORS AND POSITION
|
|
602
605
|
const query = `*[_type == 'learning-path' && brand == '${brand}'] {
|
|
603
|
-
${getFieldsForContentType(
|
|
604
|
-
"position": count(*[_type == 'learning-path' && brand == '${brand}' && (published_on < ^.published_on || (published_on == ^.published_on && _id < ^._id))]) + 1
|
|
606
|
+
${ getFieldsForContentType() },
|
|
607
|
+
"position": count(*[_type == 'learning-path' && brand == '${brand}' && (published_on < ^.published_on || (published_on == ^.published_on && _id < ^._id))]) + 1
|
|
605
608
|
} | order(published_on asc)`
|
|
606
609
|
return fetchSanity(query, true);
|
|
607
610
|
}
|
|
@@ -628,9 +631,7 @@ export async function fetchMethod(brand, slug) {
|
|
|
628
631
|
{
|
|
629
632
|
"id": railcontent_id,
|
|
630
633
|
published_on,
|
|
631
|
-
child_count,
|
|
632
634
|
difficulty,
|
|
633
|
-
difficulty_string,
|
|
634
635
|
"thumbnail_url": thumbnail.asset->url,
|
|
635
636
|
"instructor": instructor[]->{name},
|
|
636
637
|
title,
|
|
@@ -643,6 +644,15 @@ export async function fetchMethod(brand, slug) {
|
|
|
643
644
|
return fetchSanity(query, false);
|
|
644
645
|
}
|
|
645
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Fetch the child courses for a specific method by Railcontent ID.
|
|
649
|
+
* @param {string} railcontentId - The Railcontent ID of the current lesson.
|
|
650
|
+
* @returns {Promise<Object|null>} - The fetched next lesson data or null if not found.
|
|
651
|
+
*/
|
|
652
|
+
export async function fetchMethodChildren(railcontentId) {
|
|
653
|
+
return fetchChildren(railcontentId, 'method');
|
|
654
|
+
}
|
|
655
|
+
|
|
646
656
|
/**
|
|
647
657
|
* Fetch the next lesson for a specific method by Railcontent ID.
|
|
648
658
|
* @param {string} railcontentId - The Railcontent ID of the current lesson.
|