musora-content-services 1.0.236 → 1.0.237
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 +14 -9
- package/test/sanityQueryService.test.js +5 -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.237](https://github.com/railroadmedia/musora-content-services/compare/v1.0.236...v1.0.237) (2024-12-14)
|
|
6
|
+
|
|
5
7
|
### [1.0.236](https://github.com/railroadmedia/musora-content-services/compare/v1.0.235...v1.0.236) (2024-12-13)
|
|
6
8
|
|
|
7
9
|
### [1.0.235](https://github.com/railroadmedia/musora-content-services/compare/v1.0.234...v1.0.235) (2024-12-13)
|
package/package.json
CHANGED
package/src/services/sanity.js
CHANGED
|
@@ -522,12 +522,12 @@ export async function fetchAll(brand, type, {
|
|
|
522
522
|
// Construct the type filter
|
|
523
523
|
let typeFilter;
|
|
524
524
|
|
|
525
|
-
if(
|
|
525
|
+
if (type === 'archives') {
|
|
526
526
|
typeFilter = `&& status == "archived"`;
|
|
527
527
|
bypassStatusAndPublishedValidation = true;
|
|
528
528
|
} else {
|
|
529
529
|
typeFilter = type ? `&& _type == '${type}'` : "";
|
|
530
|
-
}
|
|
530
|
+
}
|
|
531
531
|
|
|
532
532
|
// Construct the search filter
|
|
533
533
|
const searchFilter = searchTerm
|
|
@@ -836,13 +836,13 @@ export async function fetchAllFilterOptions(
|
|
|
836
836
|
const constructCommonFilter = (excludeFilter) => {
|
|
837
837
|
const filterWithoutOption = excludeFilter ? filtersToGroq(filters, excludeFilter) : includedFieldsFilter;
|
|
838
838
|
const statusFilter = ' && status == "published"';
|
|
839
|
-
const includeStatusFilter = !isAdmin && !['instructor','artist','genre'].includes(contentType);
|
|
839
|
+
const includeStatusFilter = !isAdmin && !['instructor', 'artist', 'genre'].includes(contentType);
|
|
840
840
|
|
|
841
841
|
return coachId
|
|
842
842
|
? `brand == '${brand}' && status == "published" && references(*[_type=='instructor' && railcontent_id == ${coachId}]._id) ${filterWithoutOption || ''} ${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}`
|
|
843
843
|
: `_type == '${contentType}' && brand == "${brand}"${includeStatusFilter ? statusFilter : ''}${style && excludeFilter !== "style" ? ` && '${style}' in genre[]->name` : ''}${artist && excludeFilter !== "artist" ? ` && artist->name == '${artist}'` : ''} ${progressFilter} ${filterWithoutOption || ''} ${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}`;
|
|
844
844
|
};
|
|
845
|
-
|
|
845
|
+
|
|
846
846
|
const metaData = processMetadata(brand, contentType, true);
|
|
847
847
|
const allowableFilters = metaData?.allowableFilters || [];
|
|
848
848
|
const tabs = metaData?.tabs || [];
|
|
@@ -1604,15 +1604,17 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1604
1604
|
}
|
|
1605
1605
|
|
|
1606
1606
|
export async function fetchTopLevelParentId(railcontentId) {
|
|
1607
|
+
const statusFilter = "&& status in ['scheduled', 'published', 'archived', 'unlisted']";
|
|
1608
|
+
|
|
1607
1609
|
const query = `*[railcontent_id == ${railcontentId}]{
|
|
1608
1610
|
railcontent_id,
|
|
1609
|
-
'parents': *[^._id in child[]._ref
|
|
1611
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1610
1612
|
railcontent_id,
|
|
1611
|
-
'parents': *[^._id in child[]._ref
|
|
1613
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1612
1614
|
railcontent_id,
|
|
1613
|
-
'parents': *[^._id in child[]._ref
|
|
1615
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1614
1616
|
railcontent_id,
|
|
1615
|
-
'parents': *[^._id in child[]._ref
|
|
1617
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1616
1618
|
railcontent_id,
|
|
1617
1619
|
}
|
|
1618
1620
|
}
|
|
@@ -1656,6 +1658,7 @@ export async function fetchHierarchy(railcontentId) {
|
|
|
1656
1658
|
let response = await fetchSanity(query, false, {processNeedAccess: false});
|
|
1657
1659
|
if (!response) return null;
|
|
1658
1660
|
let data = {
|
|
1661
|
+
topLevelId: topLevelId,
|
|
1659
1662
|
parents: {},
|
|
1660
1663
|
children: {}
|
|
1661
1664
|
};
|
|
@@ -2049,7 +2052,9 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
|
|
|
2049
2052
|
][count > 0],`;
|
|
2050
2053
|
break;
|
|
2051
2054
|
case "type":
|
|
2052
|
-
const typesString = types.map(t => {
|
|
2055
|
+
const typesString = types.map(t => {
|
|
2056
|
+
return `{"type": "${t}"}`
|
|
2057
|
+
}).join(', ');
|
|
2053
2058
|
filterGroq = `"type": [${typesString}]{type, 'count': count(*[_type == ^.type && ${commonFilter}])}[count > 0],`;
|
|
2054
2059
|
break;
|
|
2055
2060
|
case "genre":
|
|
@@ -668,6 +668,11 @@ describe('Sanity Queries', function () {
|
|
|
668
668
|
expect(hierarchy.children[243085]).toStrictEqual([243170, 243171, 243172, 243174, 243176]);
|
|
669
669
|
});
|
|
670
670
|
|
|
671
|
+
test('fetchTopLeveldrafts', async () => {
|
|
672
|
+
let id = await fetchTopLevelParentId(413955);
|
|
673
|
+
expect(id).toBe(413955);
|
|
674
|
+
});
|
|
675
|
+
|
|
671
676
|
test('fetchCommentData', async()=>{
|
|
672
677
|
let data = await fetchCommentModContentData([241251,241252, 211153]);
|
|
673
678
|
expect(data[241251].title).toBe("Setting Up Your Space");
|