musora-content-services 1.0.190 → 1.0.191
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/services/sanity.js +29 -3
- package/test/sanityQueryService.test.js +7 -0
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.191](https://github.com/railroadmedia/musora-content-services/compare/v1.0.190...v1.0.191) (2024-11-28)
|
|
6
|
+
|
|
5
7
|
### [1.0.190](https://github.com/railroadmedia/musora-content-services/compare/v1.0.189...v1.0.190) (2024-11-28)
|
|
6
8
|
|
|
7
9
|
### [1.0.189](https://github.com/railroadmedia/musora-content-services/compare/v1.0.188...v1.0.189) (2024-11-28)
|
package/package.json
CHANGED
package/src/services/sanity.js
CHANGED
|
@@ -632,9 +632,35 @@ async function handleCustomFetchAll(brand, type, {
|
|
|
632
632
|
} = {}) {
|
|
633
633
|
if (type === 'challenge') {
|
|
634
634
|
if (groupBy === 'completed') {
|
|
635
|
-
|
|
635
|
+
const completedIds = fetchCompletedChallenges(brand, page, limit);
|
|
636
|
+
return fetchAll(brand, type,
|
|
637
|
+
{
|
|
638
|
+
page,
|
|
639
|
+
limit,
|
|
640
|
+
searchTerm,
|
|
641
|
+
sort,
|
|
642
|
+
includedFields,
|
|
643
|
+
groupBy,
|
|
644
|
+
completedIds,
|
|
645
|
+
useDefaultFields,
|
|
646
|
+
customFields,
|
|
647
|
+
progress
|
|
648
|
+
});
|
|
636
649
|
} else if (groupBy === 'owned') {
|
|
637
|
-
|
|
650
|
+
const ownedIds = fetchOwnedChallenges(brand, page, limit);
|
|
651
|
+
return fetchAll(brand, type,
|
|
652
|
+
{
|
|
653
|
+
page,
|
|
654
|
+
limit,
|
|
655
|
+
searchTerm,
|
|
656
|
+
sort,
|
|
657
|
+
includedFields,
|
|
658
|
+
groupBy,
|
|
659
|
+
ownedIds,
|
|
660
|
+
useDefaultFields,
|
|
661
|
+
customFields,
|
|
662
|
+
progress
|
|
663
|
+
});
|
|
638
664
|
} else if (groupBy === 'difficulty_string') {
|
|
639
665
|
return fetchChallengesByDifficulty(brand, type, page, limit, searchTerm, sort, includedFields, groupBy, progressIds, useDefaultFields, customFields, progress);
|
|
640
666
|
}
|
|
@@ -688,7 +714,7 @@ async function fetchChallengesByDifficulty(brand, type, page, limit, searchTerm,
|
|
|
688
714
|
"total": 0
|
|
689
715
|
}`;
|
|
690
716
|
let data = await fetchSanity(query, true);
|
|
691
|
-
data.entity = data.entity.filter(function(difficulty){
|
|
717
|
+
data.entity = data.entity.filter(function (difficulty) {
|
|
692
718
|
return difficulty.lessons.length > 0;
|
|
693
719
|
});
|
|
694
720
|
return data;
|
|
@@ -269,6 +269,13 @@ describe('Sanity Queries', function () {
|
|
|
269
269
|
expect(response.entity[0].lessons.length).toBeGreaterThan(0)
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
+
test('fetchAllChallengesByDifficulty', async () => {
|
|
273
|
+
const response = await fetchAll('drumeo', 'challenge', {groupBy:'difficulty_string'});
|
|
274
|
+
expect(response.entity[0].name).toBeDefined();
|
|
275
|
+
expect(response.entity[0].lessons).toBeDefined();
|
|
276
|
+
expect(response.entity[0].lessons.length).toBeGreaterThan(0)
|
|
277
|
+
});
|
|
278
|
+
|
|
272
279
|
test('fetchAll-CustomFields', async () => {
|
|
273
280
|
let response = await fetchAll('drumeo', 'challenge', {customFields: ['garbage']});
|
|
274
281
|
log(response);
|