musora-content-services 1.0.235 → 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 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.237](https://github.com/railroadmedia/musora-content-services/compare/v1.0.236...v1.0.237) (2024-12-14)
6
+
7
+ ### [1.0.236](https://github.com/railroadmedia/musora-content-services/compare/v1.0.235...v1.0.236) (2024-12-13)
8
+
5
9
  ### [1.0.235](https://github.com/railroadmedia/musora-content-services/compare/v1.0.234...v1.0.235) (2024-12-13)
6
10
 
7
11
  ### [1.0.234](https://github.com/railroadmedia/musora-content-services/compare/v1.0.233...v1.0.234) (2024-12-13)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.235",
3
+ "version": "1.0.237",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -518,15 +518,16 @@ export async function fetchAll(brand, type, {
518
518
  const start = (page - 1) * limit;
519
519
  const end = start + limit;
520
520
  let bypassStatusAndPublishedValidation = (type == 'instructor' || groupBy == 'artist' || groupBy == 'genre' || groupBy == 'instructor');
521
-
521
+ let bypassPermissions = bypassStatusAndPublishedValidation;
522
522
  // Construct the type filter
523
523
  let typeFilter;
524
524
 
525
- if( type === 'archives' ) {
526
- typeFilter = `&& status == "archived"`
525
+ if (type === 'archives') {
526
+ typeFilter = `&& status == "archived"`;
527
+ bypassStatusAndPublishedValidation = true;
527
528
  } else {
528
529
  typeFilter = type ? `&& _type == '${type}'` : "";
529
- }
530
+ }
530
531
 
531
532
  // Construct the search filter
532
533
  const searchFilter = searchTerm
@@ -598,7 +599,7 @@ export async function fetchAll(brand, type, {
598
599
 
599
600
  const filterWithRestrictions = await new FilterBuilder(filter, {
600
601
  bypassStatuses: bypassStatusAndPublishedValidation,
601
- bypassPermissions: bypassStatusAndPublishedValidation,
602
+ bypassPermissions: bypassPermissions,
602
603
  bypassPublishedDateRestriction: bypassStatusAndPublishedValidation
603
604
  }).buildFilter();
604
605
  query = buildEntityAndTotalQuery(
@@ -835,13 +836,13 @@ export async function fetchAllFilterOptions(
835
836
  const constructCommonFilter = (excludeFilter) => {
836
837
  const filterWithoutOption = excludeFilter ? filtersToGroq(filters, excludeFilter) : includedFieldsFilter;
837
838
  const statusFilter = ' && status == "published"';
838
- const includeStatusFilter = !isAdmin && !['instructor','artist','genre'].includes(contentType);
839
+ const includeStatusFilter = !isAdmin && !['instructor', 'artist', 'genre'].includes(contentType);
839
840
 
840
841
  return coachId
841
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}")` : ''}`
842
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}")` : ''}`;
843
844
  };
844
-
845
+
845
846
  const metaData = processMetadata(brand, contentType, true);
846
847
  const allowableFilters = metaData?.allowableFilters || [];
847
848
  const tabs = metaData?.tabs || [];
@@ -1603,15 +1604,17 @@ export async function fetchGenreLessons(brand, name, contentType, {
1603
1604
  }
1604
1605
 
1605
1606
  export async function fetchTopLevelParentId(railcontentId) {
1607
+ const statusFilter = "&& status in ['scheduled', 'published', 'archived', 'unlisted']";
1608
+
1606
1609
  const query = `*[railcontent_id == ${railcontentId}]{
1607
1610
  railcontent_id,
1608
- 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1611
+ 'parents': *[^._id in child[]._ref ${statusFilter}]{
1609
1612
  railcontent_id,
1610
- 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1613
+ 'parents': *[^._id in child[]._ref ${statusFilter}]{
1611
1614
  railcontent_id,
1612
- 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1615
+ 'parents': *[^._id in child[]._ref ${statusFilter}]{
1613
1616
  railcontent_id,
1614
- 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1617
+ 'parents': *[^._id in child[]._ref ${statusFilter}]{
1615
1618
  railcontent_id,
1616
1619
  }
1617
1620
  }
@@ -1655,6 +1658,7 @@ export async function fetchHierarchy(railcontentId) {
1655
1658
  let response = await fetchSanity(query, false, {processNeedAccess: false});
1656
1659
  if (!response) return null;
1657
1660
  let data = {
1661
+ topLevelId: topLevelId,
1658
1662
  parents: {},
1659
1663
  children: {}
1660
1664
  };
@@ -2048,7 +2052,9 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
2048
2052
  ][count > 0],`;
2049
2053
  break;
2050
2054
  case "type":
2051
- const typesString = types.map(t => {return `{"type": "${t}"}`}).join(', ');
2055
+ const typesString = types.map(t => {
2056
+ return `{"type": "${t}"}`
2057
+ }).join(', ');
2052
2058
  filterGroq = `"type": [${typesString}]{type, 'count': count(*[_type == ^.type && ${commonFilter}])}[count > 0],`;
2053
2059
  break;
2054
2060
  case "genre":
@@ -156,15 +156,15 @@ describe('contentProgressDataContext', function () {
156
156
  });
157
157
 
158
158
 
159
- test('recordWatchSession', async () => {
160
- const contentId = 241250;
161
- let progress = await getProgressPercentage(contentId); //force load context
162
-
163
- await recordWatchSession(contentId, 'video', 'vimeo', 1673, 554, 5);
164
- progress = await getProgressPercentage(241250);
165
-
166
- expect(progress).toBe(33);
167
- });
159
+ // test('recordWatchSession', async () => {
160
+ // const contentId = 241250;
161
+ // let progress = await getProgressPercentage(contentId); //force load context
162
+ //
163
+ // await recordWatchSession(contentId, 'video', 'vimeo', 1673, 554, 5);
164
+ // progress = await getProgressPercentage(241250);
165
+ //
166
+ // expect(progress).toBe(33);
167
+ // });
168
168
  // test('assignmentCompleteBubblingToCompleted', async () => {
169
169
  // let assignmentId = 241685;
170
170
  // let contentId = 241257;
@@ -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");