musora-content-services 1.0.40 → 1.0.42
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/docs/config.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/module-Config.html +1 -1
- package/docs/module-Railcontent-Services.html +1 -1
- package/docs/module-Sanity-Services.html +18 -18
- package/docs/railcontent.js.html +1 -1
- package/docs/sanity.js.html +39 -93
- package/package.json +1 -1
- package/src/services/sanity.js +38 -92
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.42](https://github.com/railroadmedia/musora-content-services/compare/v1.0.41...v1.0.42) (2024-08-20)
|
|
6
|
+
|
|
7
|
+
### [1.0.41](https://github.com/railroadmedia/musora-content-services/compare/v1.0.40...v1.0.41) (2024-08-20)
|
|
8
|
+
|
|
5
9
|
### [1.0.40](https://github.com/railroadmedia/musora-content-services/compare/v1.0.39...v1.0.40) (2024-08-20)
|
|
6
10
|
|
|
7
11
|
### [1.0.39](https://github.com/railroadmedia/musora-content-services/compare/v1.0.37...v1.0.39) (2024-08-20)
|
package/docs/config.js.html
CHANGED
|
@@ -111,7 +111,7 @@ module.exports = {
|
|
|
111
111
|
<br class="clear">
|
|
112
112
|
|
|
113
113
|
<footer>
|
|
114
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
114
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
115
115
|
</footer>
|
|
116
116
|
|
|
117
117
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -110,7 +110,7 @@ Run the following to execute the tests</p>
|
|
|
110
110
|
<br class="clear">
|
|
111
111
|
|
|
112
112
|
<footer>
|
|
113
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
113
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
114
114
|
</footer>
|
|
115
115
|
|
|
116
116
|
<script>prettyPrint();</script>
|
package/docs/module-Config.html
CHANGED
|
@@ -656,7 +656,7 @@ initializeService({
|
|
|
656
656
|
<br class="clear">
|
|
657
657
|
|
|
658
658
|
<footer>
|
|
659
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
659
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
660
660
|
</footer>
|
|
661
661
|
|
|
662
662
|
<script>prettyPrint();</script>
|
|
@@ -783,7 +783,7 @@
|
|
|
783
783
|
<br class="clear">
|
|
784
784
|
|
|
785
785
|
<footer>
|
|
786
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
786
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
787
787
|
</footer>
|
|
788
788
|
|
|
789
789
|
<script>prettyPrint();</script>
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
|
|
101
101
|
<dt class="tag-source">Source:</dt>
|
|
102
102
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
103
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
103
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line414">line 414</a>
|
|
104
104
|
</li></ul></dd>
|
|
105
105
|
|
|
106
106
|
|
|
@@ -593,7 +593,7 @@ The filter options are dynamically generated based on the provided filters, styl
|
|
|
593
593
|
|
|
594
594
|
<dt class="tag-source">Source:</dt>
|
|
595
595
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
596
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
596
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line556">line 556</a>
|
|
597
597
|
</li></ul></dd>
|
|
598
598
|
|
|
599
599
|
|
|
@@ -1566,7 +1566,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
1566
1566
|
|
|
1567
1567
|
<dt class="tag-source">Source:</dt>
|
|
1568
1568
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1569
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
1569
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line347">line 347</a>
|
|
1570
1570
|
</li></ul></dd>
|
|
1571
1571
|
|
|
1572
1572
|
|
|
@@ -1731,7 +1731,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
1731
1731
|
|
|
1732
1732
|
<dt class="tag-source">Source:</dt>
|
|
1733
1733
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1734
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
1734
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line373">line 373</a>
|
|
1735
1735
|
</li></ul></dd>
|
|
1736
1736
|
|
|
1737
1737
|
|
|
@@ -1896,7 +1896,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
1896
1896
|
|
|
1897
1897
|
<dt class="tag-source">Source:</dt>
|
|
1898
1898
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1899
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
1899
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line596">line 596</a>
|
|
1900
1900
|
</li></ul></dd>
|
|
1901
1901
|
|
|
1902
1902
|
|
|
@@ -2054,7 +2054,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
2054
2054
|
|
|
2055
2055
|
<dt class="tag-source">Source:</dt>
|
|
2056
2056
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2057
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
2057
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line768">line 768</a>
|
|
2058
2058
|
</li></ul></dd>
|
|
2059
2059
|
|
|
2060
2060
|
|
|
@@ -2219,7 +2219,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
2219
2219
|
|
|
2220
2220
|
<dt class="tag-source">Source:</dt>
|
|
2221
2221
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2222
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
2222
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line674">line 674</a>
|
|
2223
2223
|
</li></ul></dd>
|
|
2224
2224
|
|
|
2225
2225
|
|
|
@@ -2384,7 +2384,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
2384
2384
|
|
|
2385
2385
|
<dt class="tag-source">Source:</dt>
|
|
2386
2386
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2387
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
2387
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line638">line 638</a>
|
|
2388
2388
|
</li></ul></dd>
|
|
2389
2389
|
|
|
2390
2390
|
|
|
@@ -2542,7 +2542,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
2542
2542
|
|
|
2543
2543
|
<dt class="tag-source">Source:</dt>
|
|
2544
2544
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2545
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
2545
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line617">line 617</a>
|
|
2546
2546
|
</li></ul></dd>
|
|
2547
2547
|
|
|
2548
2548
|
|
|
@@ -2700,7 +2700,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
2700
2700
|
|
|
2701
2701
|
<dt class="tag-source">Source:</dt>
|
|
2702
2702
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2703
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
2703
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line271">line 271</a>
|
|
2704
2704
|
</li></ul></dd>
|
|
2705
2705
|
|
|
2706
2706
|
|
|
@@ -2858,7 +2858,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
2858
2858
|
|
|
2859
2859
|
<dt class="tag-source">Source:</dt>
|
|
2860
2860
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2861
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
2861
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line648">line 648</a>
|
|
2862
2862
|
</li></ul></dd>
|
|
2863
2863
|
|
|
2864
2864
|
|
|
@@ -3016,7 +3016,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
3016
3016
|
|
|
3017
3017
|
<dt class="tag-source">Source:</dt>
|
|
3018
3018
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3019
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
3019
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line728">line 728</a>
|
|
3020
3020
|
</li></ul></dd>
|
|
3021
3021
|
|
|
3022
3022
|
|
|
@@ -3174,7 +3174,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
3174
3174
|
|
|
3175
3175
|
<dt class="tag-source">Source:</dt>
|
|
3176
3176
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3177
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
3177
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line754">line 754</a>
|
|
3178
3178
|
</li></ul></dd>
|
|
3179
3179
|
|
|
3180
3180
|
|
|
@@ -3339,7 +3339,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
3339
3339
|
|
|
3340
3340
|
<dt class="tag-source">Source:</dt>
|
|
3341
3341
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3342
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
3342
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line707">line 707</a>
|
|
3343
3343
|
</li></ul></dd>
|
|
3344
3344
|
|
|
3345
3345
|
|
|
@@ -3710,7 +3710,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
|
|
|
3710
3710
|
|
|
3711
3711
|
<dt class="tag-source">Source:</dt>
|
|
3712
3712
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3713
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
3713
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line809">line 809</a>
|
|
3714
3714
|
</li></ul></dd>
|
|
3715
3715
|
|
|
3716
3716
|
|
|
@@ -4546,7 +4546,7 @@ fetchSanity(query, true)
|
|
|
4546
4546
|
|
|
4547
4547
|
<dt class="tag-source">Source:</dt>
|
|
4548
4548
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
4549
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
4549
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line308">line 308</a>
|
|
4550
4550
|
</li></ul></dd>
|
|
4551
4551
|
|
|
4552
4552
|
|
|
@@ -4713,7 +4713,7 @@ It also includes completion status and progress percentage for each workout by f
|
|
|
4713
4713
|
|
|
4714
4714
|
<dt class="tag-source">Source:</dt>
|
|
4715
4715
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
4716
|
-
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#
|
|
4716
|
+
<a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line249">line 249</a>
|
|
4717
4717
|
</li></ul></dd>
|
|
4718
4718
|
|
|
4719
4719
|
|
|
@@ -4877,7 +4877,7 @@ It also includes completion status and progress percentage for each workout by f
|
|
|
4877
4877
|
<br class="clear">
|
|
4878
4878
|
|
|
4879
4879
|
<footer>
|
|
4880
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
4880
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
4881
4881
|
</footer>
|
|
4882
4882
|
|
|
4883
4883
|
<script>prettyPrint();</script>
|
package/docs/railcontent.js.html
CHANGED
|
@@ -201,7 +201,7 @@ export async function fetchContentInProgress(type="all", brand) {
|
|
|
201
201
|
<br class="clear">
|
|
202
202
|
|
|
203
203
|
<footer>
|
|
204
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
204
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
205
205
|
</footer>
|
|
206
206
|
|
|
207
207
|
<script>prettyPrint();</script>
|
package/docs/sanity.js.html
CHANGED
|
@@ -293,74 +293,23 @@ export async function fetchSongCount(brand) {
|
|
|
293
293
|
* .then(workouts => console.log(workouts))
|
|
294
294
|
* .catch(error => console.error(error));
|
|
295
295
|
*/
|
|
296
|
-
|
|
297
296
|
export async function fetchWorkouts(brand) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
try {
|
|
313
|
-
// Fetch the workouts
|
|
314
|
-
const workouts = await fetchSanity(query, true);
|
|
315
|
-
|
|
316
|
-
if (!workouts || workouts.length === 0) {
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Extract content IDs
|
|
321
|
-
const contentIds = workouts.map(workout => workout.id);
|
|
322
|
-
|
|
323
|
-
// Fetch completion states using the existing function
|
|
324
|
-
const completedStatesObject = await fetchAllCompletedStates(contentIds);
|
|
325
|
-
|
|
326
|
-
// Check if completedStatesObject is an object and convert to array if necessary
|
|
327
|
-
if (typeof completedStatesObject !== 'object' || completedStatesObject === null) {
|
|
328
|
-
console.error('Completed states are not an object:', completedStatesObject);
|
|
329
|
-
return workouts;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// Convert object to array and create a map for fast lookup
|
|
333
|
-
const completedStatesArray = Object.entries(completedStatesObject).map(([content_id, state]) => ({
|
|
334
|
-
content_id: parseInt(content_id, 10), // Convert key to integer if necessary
|
|
335
|
-
...state
|
|
336
|
-
}));
|
|
337
|
-
|
|
338
|
-
const completedStatesMap = completedStatesArray.reduce((map, state) => {
|
|
339
|
-
map[state.content_id] = state;
|
|
340
|
-
return map;
|
|
341
|
-
}, {});
|
|
342
|
-
|
|
343
|
-
// Add completion status and progress percentage to each workout
|
|
344
|
-
return workouts.map(workout => {
|
|
345
|
-
const state = completedStatesMap[workout.id];
|
|
346
|
-
if (state) {
|
|
347
|
-
workout.completed = state.state !== "not started";
|
|
348
|
-
workout.progress_percent = state.percent.toString();
|
|
349
|
-
} else {
|
|
350
|
-
workout.completed = false;
|
|
351
|
-
workout.progress_percent = "0";
|
|
352
|
-
}
|
|
353
|
-
//console.log(workout)
|
|
354
|
-
return workout;
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
} catch (error) {
|
|
358
|
-
console.error('Error fetching workouts with completion:', error);
|
|
359
|
-
return [];
|
|
360
|
-
}
|
|
297
|
+
const query = `*[_type == 'workout' && brand == '${brand}'] [0...5] {
|
|
298
|
+
"id": railcontent_id,
|
|
299
|
+
title,
|
|
300
|
+
"image": thumbnail.asset->url,
|
|
301
|
+
"artist_name": instructor[0]->name,
|
|
302
|
+
"artists": instructor[]->name,
|
|
303
|
+
difficulty,
|
|
304
|
+
difficulty_string,
|
|
305
|
+
length_in_seconds,
|
|
306
|
+
published_on,
|
|
307
|
+
"type": _type,
|
|
308
|
+
web_url_path,
|
|
309
|
+
} | order(published_on desc)[0...5]`
|
|
310
|
+
return fetchSanity(query, true);
|
|
361
311
|
}
|
|
362
312
|
|
|
363
|
-
|
|
364
313
|
/**
|
|
365
314
|
* Fetch the latest new releases for a specific brand.
|
|
366
315
|
* @param {string} brand - The brand for which to fetch new releases.
|
|
@@ -659,34 +608,31 @@ export async function fetchAllFilterOptions(
|
|
|
659
608
|
contentType,
|
|
660
609
|
term
|
|
661
610
|
) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
}
|
|
611
|
+
const query = `
|
|
612
|
+
{
|
|
613
|
+
"meta": {
|
|
614
|
+
"totalResults": count(*[_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''}${filters}
|
|
615
|
+
${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}]),
|
|
616
|
+
"filterOptions": {
|
|
617
|
+
"difficulty": [
|
|
618
|
+
{"type": "Introductory", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Introductory"${filters}])},
|
|
619
|
+
{"type": "Beginner", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Beginner"${filters}])},
|
|
620
|
+
{"type": "Intermediate", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Intermediate"${filters}])},
|
|
621
|
+
{"type": "Advanced", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Advanced"${filters}])},
|
|
622
|
+
{"type": "Expert", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Expert"${filters}])}
|
|
623
|
+
][count > 0],
|
|
624
|
+
"instrumentless": [
|
|
625
|
+
{"type": "Full Song Only", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && instrumentless == false${filters}])},
|
|
626
|
+
{"type": "Instrument Removed", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && instrumentless == true${filters}])}
|
|
627
|
+
][count > 0],
|
|
628
|
+
"genre": *[_type == 'genre' && '${contentType}' in filter_types] {
|
|
629
|
+
"type": name,
|
|
630
|
+
"count": count(*[_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && references(^._id)])
|
|
631
|
+
}[count > 0]
|
|
685
632
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
return fetchSanity(query, false);
|
|
633
|
+
}
|
|
634
|
+
}`;
|
|
635
|
+
return fetchSanity(query, true);
|
|
690
636
|
}
|
|
691
637
|
|
|
692
638
|
/**
|
|
@@ -989,7 +935,7 @@ function checkSanityConfig(config) {
|
|
|
989
935
|
<br class="clear">
|
|
990
936
|
|
|
991
937
|
<footer>
|
|
992
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024
|
|
938
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 20 2024 20:28:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
993
939
|
</footer>
|
|
994
940
|
|
|
995
941
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
package/src/services/sanity.js
CHANGED
|
@@ -246,74 +246,23 @@ export async function fetchSongCount(brand) {
|
|
|
246
246
|
* .then(workouts => console.log(workouts))
|
|
247
247
|
* .catch(error => console.error(error));
|
|
248
248
|
*/
|
|
249
|
-
|
|
250
249
|
export async function fetchWorkouts(brand) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
try {
|
|
266
|
-
// Fetch the workouts
|
|
267
|
-
const workouts = await fetchSanity(query, true);
|
|
268
|
-
|
|
269
|
-
if (!workouts || workouts.length === 0) {
|
|
270
|
-
return [];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Extract content IDs
|
|
274
|
-
const contentIds = workouts.map(workout => workout.id);
|
|
275
|
-
|
|
276
|
-
// Fetch completion states using the existing function
|
|
277
|
-
const completedStatesObject = await fetchAllCompletedStates(contentIds);
|
|
278
|
-
|
|
279
|
-
// Check if completedStatesObject is an object and convert to array if necessary
|
|
280
|
-
if (typeof completedStatesObject !== 'object' || completedStatesObject === null) {
|
|
281
|
-
console.error('Completed states are not an object:', completedStatesObject);
|
|
282
|
-
return workouts;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Convert object to array and create a map for fast lookup
|
|
286
|
-
const completedStatesArray = Object.entries(completedStatesObject).map(([content_id, state]) => ({
|
|
287
|
-
content_id: parseInt(content_id, 10), // Convert key to integer if necessary
|
|
288
|
-
...state
|
|
289
|
-
}));
|
|
290
|
-
|
|
291
|
-
const completedStatesMap = completedStatesArray.reduce((map, state) => {
|
|
292
|
-
map[state.content_id] = state;
|
|
293
|
-
return map;
|
|
294
|
-
}, {});
|
|
295
|
-
|
|
296
|
-
// Add completion status and progress percentage to each workout
|
|
297
|
-
return workouts.map(workout => {
|
|
298
|
-
const state = completedStatesMap[workout.id];
|
|
299
|
-
if (state) {
|
|
300
|
-
workout.completed = state.state !== "not started";
|
|
301
|
-
workout.progress_percent = state.percent.toString();
|
|
302
|
-
} else {
|
|
303
|
-
workout.completed = false;
|
|
304
|
-
workout.progress_percent = "0";
|
|
305
|
-
}
|
|
306
|
-
//console.log(workout)
|
|
307
|
-
return workout;
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
} catch (error) {
|
|
311
|
-
console.error('Error fetching workouts with completion:', error);
|
|
312
|
-
return [];
|
|
313
|
-
}
|
|
250
|
+
const query = `*[_type == 'workout' && brand == '${brand}'] [0...5] {
|
|
251
|
+
"id": railcontent_id,
|
|
252
|
+
title,
|
|
253
|
+
"image": thumbnail.asset->url,
|
|
254
|
+
"artist_name": instructor[0]->name,
|
|
255
|
+
"artists": instructor[]->name,
|
|
256
|
+
difficulty,
|
|
257
|
+
difficulty_string,
|
|
258
|
+
length_in_seconds,
|
|
259
|
+
published_on,
|
|
260
|
+
"type": _type,
|
|
261
|
+
web_url_path,
|
|
262
|
+
} | order(published_on desc)[0...5]`
|
|
263
|
+
return fetchSanity(query, true);
|
|
314
264
|
}
|
|
315
265
|
|
|
316
|
-
|
|
317
266
|
/**
|
|
318
267
|
* Fetch the latest new releases for a specific brand.
|
|
319
268
|
* @param {string} brand - The brand for which to fetch new releases.
|
|
@@ -612,34 +561,31 @@ export async function fetchAllFilterOptions(
|
|
|
612
561
|
contentType,
|
|
613
562
|
term
|
|
614
563
|
) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
}
|
|
564
|
+
const query = `
|
|
565
|
+
{
|
|
566
|
+
"meta": {
|
|
567
|
+
"totalResults": count(*[_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''}${filters}
|
|
568
|
+
${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}]),
|
|
569
|
+
"filterOptions": {
|
|
570
|
+
"difficulty": [
|
|
571
|
+
{"type": "Introductory", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Introductory"${filters}])},
|
|
572
|
+
{"type": "Beginner", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Beginner"${filters}])},
|
|
573
|
+
{"type": "Intermediate", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Intermediate"${filters}])},
|
|
574
|
+
{"type": "Advanced", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Advanced"${filters}])},
|
|
575
|
+
{"type": "Expert", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Expert"${filters}])}
|
|
576
|
+
][count > 0],
|
|
577
|
+
"instrumentless": [
|
|
578
|
+
{"type": "Full Song Only", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && instrumentless == false${filters}])},
|
|
579
|
+
{"type": "Instrument Removed", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && instrumentless == true${filters}])}
|
|
580
|
+
][count > 0],
|
|
581
|
+
"genre": *[_type == 'genre' && '${contentType}' in filter_types] {
|
|
582
|
+
"type": name,
|
|
583
|
+
"count": count(*[_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && references(^._id)])
|
|
584
|
+
}[count > 0]
|
|
638
585
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
return fetchSanity(query, false);
|
|
586
|
+
}
|
|
587
|
+
}`;
|
|
588
|
+
return fetchSanity(query, true);
|
|
643
589
|
}
|
|
644
590
|
|
|
645
591
|
/**
|