musora-content-services 1.0.221 → 1.0.223
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
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.223](https://github.com/railroadmedia/musora-content-services/compare/v1.0.222...v1.0.223) (2024-12-06)
|
|
6
|
+
|
|
7
|
+
### [1.0.222](https://github.com/railroadmedia/musora-content-services/compare/v1.0.221...v1.0.222) (2024-12-06)
|
|
8
|
+
|
|
5
9
|
### [1.0.221](https://github.com/railroadmedia/musora-content-services/compare/v1.0.220...v1.0.221) (2024-12-06)
|
|
6
10
|
|
|
7
11
|
### [1.0.220](https://github.com/railroadmedia/musora-content-services/compare/v1.0.219...v1.0.220) (2024-12-06)
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -461,7 +461,7 @@ function filtersToGroq(filters, selectedFilters = []) {
|
|
|
461
461
|
return `gear match "${value}"`;
|
|
462
462
|
} else if (key === 'instrumentless' && !selectedFilters.includes(key)) {
|
|
463
463
|
if (value === "Full Song Only") {
|
|
464
|
-
return `(!instrumentless || instrumentless
|
|
464
|
+
return `(!instrumentless || instrumentless == null)`;
|
|
465
465
|
} else if (value === "Instrument Removed") {
|
|
466
466
|
return `instrumentless`;
|
|
467
467
|
} else {
|
package/src/services/sanity.js
CHANGED
|
@@ -828,12 +828,16 @@ export async function fetchAllFilterOptions(
|
|
|
828
828
|
|
|
829
829
|
const includedFieldsFilter = filters?.length ? filtersToGroq(filters) : undefined;
|
|
830
830
|
const progressFilter = progressIds ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
|
|
831
|
+
const isAdmin = (await fetchUserPermissions()).isAdmin;
|
|
831
832
|
|
|
832
833
|
const constructCommonFilter = (excludeFilter) => {
|
|
833
834
|
const filterWithoutOption = excludeFilter ? filtersToGroq(filters, excludeFilter) : includedFieldsFilter;
|
|
835
|
+
const statusFilter = ' && status == "published"';
|
|
836
|
+
const includeStatusFilter = !isAdmin && !['instructor','artist','genre'].includes(contentType);
|
|
837
|
+
|
|
834
838
|
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 || ''}`;
|
|
839
|
+
? `brand == '${brand}' && status == "published" && references(*[_type=='instructor' && railcontent_id == ${coachId}]._id) ${filterWithoutOption || ''}`
|
|
840
|
+
: `_type == '${contentType}' && brand == "${brand}"${includeStatusFilter ? statusFilter : ''}${style && excludeFilter !== "style" ? ` && '${style}' in genre[]->name` : ''}${artist && excludeFilter !== "artist" ? ` && artist->name == '${artist}'` : ''} ${progressFilter} ${filterWithoutOption || ''}`;
|
|
837
841
|
};
|
|
838
842
|
|
|
839
843
|
const metaData = processMetadata(brand, contentType, true);
|
|
@@ -2018,10 +2022,8 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
|
|
|
2018
2022
|
][count > 0],`;
|
|
2019
2023
|
break;
|
|
2020
2024
|
case "type":
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
}).join(', ');
|
|
2024
|
-
filterGroq = `"type": [${dynamicTypeOptions}][count > 0],`;
|
|
2025
|
+
const typesString = types.map(t => {return `{"type": "${t}"}`}).join(', ');
|
|
2026
|
+
filterGroq = `"type": [${typesString}]{type, 'count': count(*[_type == ^.type && ${commonFilter}])}[count > 0],`;
|
|
2025
2027
|
break;
|
|
2026
2028
|
case "genre":
|
|
2027
2029
|
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
|