musora-content-services 2.31.0 → 2.31.1

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.
Files changed (156) hide show
  1. package/.coderabbit.yaml +0 -0
  2. package/.editorconfig +0 -0
  3. package/.github/pull_request_template.md +0 -0
  4. package/.github/workflows/conventional-commits.yaml +0 -0
  5. package/.github/workflows/docs.js.yml +0 -0
  6. package/.github/workflows/node.js.yml +0 -0
  7. package/.prettierignore +0 -0
  8. package/.prettierrc +0 -0
  9. package/CHANGELOG.md +7 -0
  10. package/README.md +0 -0
  11. package/babel.config.cjs +0 -0
  12. package/docs/ContentOrganization.html +0 -0
  13. package/docs/Gamification.html +0 -0
  14. package/docs/UserManagementSystem.html +0 -0
  15. package/docs/api_types.js.html +0 -0
  16. package/docs/config.js.html +0 -0
  17. package/docs/content-org_content-org.js.html +0 -0
  18. package/docs/content-org_playlists-types.js.html +0 -0
  19. package/docs/content-org_playlists.js.html +0 -0
  20. package/docs/content.js.html +0 -0
  21. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  22. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  23. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  24. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  25. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  26. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  27. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  28. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  31. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  32. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  36. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  39. package/docs/gamification_awards.js.html +0 -0
  40. package/docs/gamification_gamification.js.html +0 -0
  41. package/docs/gamification_types.js.html +0 -0
  42. package/docs/global.html +0 -0
  43. package/docs/index.html +0 -0
  44. package/docs/module-Awards.html +0 -0
  45. package/docs/module-Config.html +0 -0
  46. package/docs/module-Content-Services-V2.html +0 -0
  47. package/docs/module-Interests.html +0 -0
  48. package/docs/module-Permissions.html +0 -0
  49. package/docs/module-Playlists.html +0 -0
  50. package/docs/module-Railcontent-Services.html +0 -0
  51. package/docs/module-Sanity-Services.html +0 -0
  52. package/docs/module-Sessions.html +0 -0
  53. package/docs/module-UserActivity.html +0 -0
  54. package/docs/module-UserChat.html +0 -0
  55. package/docs/module-UserManagement.html +0 -0
  56. package/docs/module-UserNotifications.html +0 -0
  57. package/docs/module-UserProfile.html +0 -0
  58. package/docs/railcontent.js.html +0 -0
  59. package/docs/sanity.js.html +0 -0
  60. package/docs/scripts/collapse.js +0 -0
  61. package/docs/scripts/commonNav.js +0 -0
  62. package/docs/scripts/linenumber.js +0 -0
  63. package/docs/scripts/nav.js +0 -0
  64. package/docs/scripts/polyfill.js +0 -0
  65. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  66. package/docs/scripts/prettify/lang-css.js +0 -0
  67. package/docs/scripts/prettify/prettify.js +0 -0
  68. package/docs/scripts/search.js +0 -0
  69. package/docs/styles/jsdoc.css +0 -0
  70. package/docs/styles/prettify.css +0 -0
  71. package/docs/userActivity.js.html +0 -0
  72. package/docs/user_chat.js.html +0 -0
  73. package/docs/user_interests.js.html +0 -0
  74. package/docs/user_management.js.html +0 -0
  75. package/docs/user_notifications.js.html +0 -0
  76. package/docs/user_permissions.js.html +0 -0
  77. package/docs/user_profile.js.html +0 -0
  78. package/docs/user_sessions.js.html +0 -0
  79. package/docs/user_types.js.html +0 -0
  80. package/docs/user_user-management-system.js.html +0 -0
  81. package/jest.config.js +0 -0
  82. package/jsdoc.json +0 -0
  83. package/package.json +1 -1
  84. package/src/contentTypeConfig.js +6 -0
  85. package/src/filterBuilder.js +0 -0
  86. package/src/index.d.ts +3 -1
  87. package/src/index.js +3 -1
  88. package/src/infrastructure/http/HttpClient.ts +0 -0
  89. package/src/infrastructure/http/executors/FetchRequestExecutor.ts +0 -0
  90. package/src/infrastructure/http/index.ts +0 -0
  91. package/src/infrastructure/http/interfaces/HeaderProvider.ts +0 -0
  92. package/src/infrastructure/http/interfaces/HttpError.ts +0 -0
  93. package/src/infrastructure/http/interfaces/NetworkError.ts +0 -0
  94. package/src/infrastructure/http/interfaces/RequestExecutor.ts +0 -0
  95. package/src/infrastructure/http/interfaces/RequestOptions.ts +0 -0
  96. package/src/infrastructure/http/providers/DefaultHeaderProvider.ts +0 -0
  97. package/src/lib/httpHelper.js +0 -0
  98. package/src/lib/lastUpdated.js +0 -0
  99. package/src/services/api/types.js +0 -0
  100. package/src/services/config.js +0 -0
  101. package/src/services/content-org/content-org.js +0 -0
  102. package/src/services/content-org/guided-courses.ts +0 -0
  103. package/src/services/content-org/playlists-types.js +0 -0
  104. package/src/services/content-org/playlists.js +0 -0
  105. package/src/services/content.js +46 -23
  106. package/src/services/contentAggregator.js +0 -0
  107. package/src/services/contentLikes.js +0 -0
  108. package/src/services/contentProgress.js +0 -0
  109. package/src/services/dataContext.js +0 -0
  110. package/src/services/dateUtils.js +0 -0
  111. package/src/services/forum.js +0 -0
  112. package/src/services/gamification/awards.js +0 -0
  113. package/src/services/gamification/gamification.js +0 -0
  114. package/src/services/gamification/types.js +0 -0
  115. package/src/services/imageSRCBuilder.js +0 -0
  116. package/src/services/imageSRCVerify.js +0 -0
  117. package/src/services/railcontent.js +19 -0
  118. package/src/services/recommendations.js +0 -0
  119. package/src/services/sanity.js +5 -50
  120. package/src/services/types.js +0 -0
  121. package/src/services/user/account.ts +0 -0
  122. package/src/services/user/chat.js +0 -0
  123. package/src/services/user/interests.js +0 -0
  124. package/src/services/user/management.js +0 -0
  125. package/src/services/user/permissions.js +0 -0
  126. package/src/services/user/profile.js +0 -0
  127. package/src/services/user/sessions.js +0 -0
  128. package/src/services/user/types.js +0 -0
  129. package/src/services/user/user-management-system.js +0 -0
  130. package/src/services/userActivity.js +0 -0
  131. package/test/HttpClient.test.js +0 -0
  132. package/test/content.test.js +0 -0
  133. package/test/contentLikes.test.js +0 -0
  134. package/test/contentProgress.test.js +3 -4
  135. package/test/dataContext.test.js +0 -0
  136. package/test/forum.test.js +0 -0
  137. package/test/imageSRCBuilder.test.js +0 -0
  138. package/test/imageSRCVerify.test.js +0 -0
  139. package/test/initializeTests.js +0 -0
  140. package/test/lib/lastUpdated.test.js +0 -0
  141. package/test/live/contentProgressLive.test.js +0 -0
  142. package/test/live/railcontentLive.test.js +0 -0
  143. package/test/localStorageMock.js +0 -0
  144. package/test/log.js +0 -0
  145. package/test/mockData/mockData_fetchByRailContentIds_one_content.json +0 -0
  146. package/test/mockData/mockData_progress_content.json +0 -0
  147. package/test/mockData/mockData_sanity_progress_content.json +0 -0
  148. package/test/mockData/mockData_user_practices.json +0 -0
  149. package/test/notifications.test.js +0 -0
  150. package/test/progressRows.test.js +0 -0
  151. package/test/sanityQueryService.test.js +0 -0
  152. package/test/streakMessage.test.js +0 -0
  153. package/test/user/permissions.test.js +0 -0
  154. package/test/userActivity.test.js +0 -0
  155. package/tools/generate-index.cjs +0 -0
  156. package/.yarnrc.yml +0 -1
package/.coderabbit.yaml CHANGED
File without changes
package/.editorconfig CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/.prettierignore CHANGED
File without changes
package/.prettierrc CHANGED
File without changes
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
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
+ ### [2.31.1](https://github.com/railroadmedia/musora-content-services/compare/v2.31.0...v2.31.1) (2025-08-14)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **MU-922:** uses BE for fetching recent content items ([#411](https://github.com/railroadmedia/musora-content-services/issues/411)) ([e85fe88](https://github.com/railroadmedia/musora-content-services/commit/e85fe881d382aadbe8fc902e959cfad2cbc98576))
11
+
5
12
  ## [2.31.0](https://github.com/railroadmedia/musora-content-services/compare/v2.30.9...v2.31.0) (2025-08-14)
6
13
 
7
14
 
package/README.md CHANGED
File without changes
package/babel.config.cjs CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/docs/global.html CHANGED
File without changes
package/docs/index.html CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/jest.config.js CHANGED
File without changes
package/jsdoc.json CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.31.0",
3
+ "version": "2.31.1",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -671,6 +671,12 @@ export function getUpcomingEventsTypes(brand) {
671
671
  }
672
672
  }
673
673
 
674
+ export function getRecentTypesForPage(pageType) {
675
+ const types = recentTypes[pageType]
676
+ // defensive copy with de-duplication to avoid accidental mutation and redundant query params
677
+ return Array.isArray(types) ? [...new Set(types)] : []
678
+ }
679
+
674
680
  export function artistOrInstructorName(key = 'artist_name') {
675
681
  return `'${key}': coalesce(artist->name, instructor[0]->name)`
676
682
  }
File without changes
package/src/index.d.ts CHANGED
@@ -38,6 +38,7 @@ import {
38
38
  getLessonContentRows,
39
39
  getNewAndUpcoming,
40
40
  getRecent,
41
+ getRecentForTab,
41
42
  getRecommendedForYou,
42
43
  getScheduleContentRows,
43
44
  getTabResults
@@ -129,6 +130,7 @@ import {
129
130
  fetchLastInteractedChild,
130
131
  fetchLikeCount,
131
132
  fetchNextContentDataForParent,
133
+ fetchRecent,
132
134
  fetchRecentUserActivities,
133
135
  fetchSongsInProgress,
134
136
  fetchTopComment,
@@ -197,7 +199,6 @@ import {
197
199
  fetchPackData,
198
200
  fetchParentForDownload,
199
201
  fetchPlayAlongsCount,
200
- fetchRecent,
201
202
  fetchRelatedLessons,
202
203
  fetchRelatedRecommendedContent,
203
204
  fetchRelatedSongs,
@@ -442,6 +443,7 @@ declare module 'musora-content-services' {
442
443
  getProgressStateByIds,
443
444
  getRecent,
444
445
  getRecentActivity,
446
+ getRecentForTab,
445
447
  getRecommendedForYou,
446
448
  getResumeTimeSeconds,
447
449
  getResumeTimeSecondsByIds,
package/src/index.js CHANGED
@@ -38,6 +38,7 @@ import {
38
38
  getLessonContentRows,
39
39
  getNewAndUpcoming,
40
40
  getRecent,
41
+ getRecentForTab,
41
42
  getRecommendedForYou,
42
43
  getScheduleContentRows,
43
44
  getTabResults
@@ -129,6 +130,7 @@ import {
129
130
  fetchLastInteractedChild,
130
131
  fetchLikeCount,
131
132
  fetchNextContentDataForParent,
133
+ fetchRecent,
132
134
  fetchRecentUserActivities,
133
135
  fetchSongsInProgress,
134
136
  fetchTopComment,
@@ -197,7 +199,6 @@ import {
197
199
  fetchPackData,
198
200
  fetchParentForDownload,
199
201
  fetchPlayAlongsCount,
200
- fetchRecent,
201
202
  fetchRelatedLessons,
202
203
  fetchRelatedRecommendedContent,
203
204
  fetchRelatedSongs,
@@ -441,6 +442,7 @@ export {
441
442
  getProgressStateByIds,
442
443
  getRecent,
443
444
  getRecentActivity,
445
+ getRecentForTab,
444
446
  getRecommendedForYou,
445
447
  getResumeTimeSeconds,
446
448
  getResumeTimeSecondsByIds,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -5,7 +5,6 @@
5
5
  import {
6
6
  fetchByRailContentIds,
7
7
  fetchMetadata,
8
- fetchRecent,
9
8
  fetchTabData,
10
9
  fetchNewReleases,
11
10
  fetchUpcomingEvents,
@@ -13,16 +12,18 @@ import {
13
12
  fetchReturning,
14
13
  fetchLeaving, fetchScheduledAndNewReleases, fetchContentRows
15
14
  } from './sanity.js'
15
+ import {getRecentTypesForPage} from '../contentTypeConfig.js'
16
16
  import {TabResponseType, Tabs, capitalizeFirstLetter} from '../contentMetaData.js'
17
- import {fetchHandler} from "./railcontent";
17
+ import {fetchRecent} from "./railcontent";
18
18
  import {recommendations, rankCategories, rankItems} from "./recommendations";
19
19
  import {addContextToContent} from "./contentAggregator.js";
20
20
 
21
+ export async function getLessonContentRows(brand, pageName) {
22
+ const [recentContentIds, contentRows] = await Promise.all([
23
+ fetchRecent(brand, { types: getRecentTypesForPage(pageName) }, { limit: 10 }),
24
+ getContentRows(brand, pageName)
25
+ ])
21
26
 
22
- export async function getLessonContentRows (brand='drumeo', pageName = 'lessons') {
23
- let recentContentIds = await fetchRecent(brand, pageName, { progress: 'recent', limit: 10 });
24
-
25
- let contentRows = await getContentRows(brand, pageName);
26
27
  contentRows = Array.isArray(contentRows) ? contentRows : [];
27
28
  contentRows.unshift({
28
29
  id: 'recent',
@@ -66,13 +67,8 @@ export async function getTabResults(brand, pageName, tabName, {
66
67
  sort = 'recommended',
67
68
  selectedFilters = []
68
69
  } = {}) {
69
- // Extract and handle 'progress' filter separately
70
- const progressFilter = selectedFilters.find(f => f.startsWith('progress,')) || 'progress,all';
71
- const progressValue = progressFilter.split(',')[1].toLowerCase();
72
- const filteredSelectedFilters = selectedFilters.filter(f => !f.startsWith('progress,'));
73
-
74
70
  // Prepare included fields
75
- const mergedIncludedFields = [...filteredSelectedFilters, `tab,${tabName.toLowerCase()}`];
71
+ const mergedIncludedFields = [...selectedFilters, `tab,${tabName.toLowerCase()}`];
76
72
 
77
73
  // Fetch data
78
74
  let results
@@ -85,7 +81,7 @@ export async function getTabResults(brand, pageName, tabName, {
85
81
  addProgressStatus: true
86
82
  })
87
83
  } else {
88
- let temp = await fetchTabData(brand, pageName, { page, limit, sort, includedFields: mergedIncludedFields, progress: progressValue });
84
+ let temp = await fetchTabData(brand, pageName, { page, limit, sort, includedFields: mergedIncludedFields });
89
85
 
90
86
  const [ranking, contextResults] = await Promise.all([
91
87
  sort === 'recommended' ? rankItems(brand, temp.entity.map(e => e.railcontent_id)) : [],
@@ -104,7 +100,6 @@ export async function getTabResults(brand, pageName, tabName, {
104
100
  })
105
101
  }
106
102
 
107
-
108
103
  // Fetch metadata
109
104
  const metaData = await fetchMetadata(brand, pageName);
110
105
 
@@ -115,8 +110,7 @@ export async function getTabResults(brand, pageName, tabName, {
115
110
  const value = item.value.split(',')[1];
116
111
  return {
117
112
  ...item,
118
- selected: selectedFilters.includes(`${filter.key},${value}`) ||
119
- (filter.key === 'progress' && value === 'all' && !selectedFilters.some(f => f.startsWith('progress,')))
113
+ selected: selectedFilters.includes(`${filter.key},${value}`)
120
114
  };
121
115
  })
122
116
  }));
@@ -151,7 +145,7 @@ export async function getTabResults(brand, pageName, tabName, {
151
145
  * @returns {Promise<Object>} - The fetched content data.
152
146
  *
153
147
  * @example
154
- * getRecent('drumeo', 'lessons', 'all', {
148
+ * getRecent('drumeo', { status: 'completed', types: ['lessons'] }, {
155
149
  * page: 2,
156
150
  * limit: 15,
157
151
  * sort: '-popularity'
@@ -159,14 +153,43 @@ export async function getTabResults(brand, pageName, tabName, {
159
153
  * .then(content => console.log(content))
160
154
  * .catch(error => console.error(error));
161
155
  */
162
- export async function getRecent(brand, pageName, tabName = 'all', {
156
+ export async function getRecent(brand, { status, types } = {}, {
163
157
  page = 1,
164
- limit = 10,
165
- sort = '-published_on',
158
+ limit = 10
166
159
  } = {}) {
167
- const progress = tabName.toLowerCase() == 'all' ? 'recent':tabName.toLowerCase();
168
- const recentContentIds = await fetchRecent(brand, pageName, { page:page, limit:limit, progress: progress });
169
- const metaData = await fetchMetadata(brand, 'recent');
160
+ return await fetchRecent(brand, { status, types }, { page, limit });
161
+ }
162
+
163
+ /**
164
+ * Fetches recent content for a given brand and page with pagination.
165
+ *
166
+ * @param {string} brand - The brand for which to fetch data.
167
+ * @param {string} pageName - The page name (e.g., 'all', 'incomplete', 'completed').
168
+ * @param {string} [tabName='all'] - The tab name (defaults to 'all' for recent content).
169
+ * @param {Object} params - Parameters for pagination and sorting.
170
+ * @param {number} [params.page=1] - The page number for pagination.
171
+ * @param {number} [params.limit=10] - The number of items per page.
172
+ * @param {string} [params.sort="-published_on"] - The field to sort the data by.
173
+ * @returns {Promise<Object>} - The fetched content data.
174
+ *
175
+ * @example
176
+ * getRecent('drumeo', 'lessons', 'all', {
177
+ * page: 2,
178
+ * limit: 15,
179
+ * sort: '-popularity'
180
+ * })
181
+ * .then(content => console.log(content))
182
+ * .catch(error => console.error(error));
183
+ */
184
+ export async function getRecentForTab(brand, pageType, tabName, { page = 1, limit = 10 } = {}) {
185
+ const types = getRecentTypesForPage(pageType)
186
+ const status = tabName === Tabs.RecentCompleted.name ? 'completed' : tabName === Tabs.RecentIncomplete.name ? 'incomplete' : null
187
+
188
+ const [recentContentIds, metaData] = await Promise.all([
189
+ fetchRecent(brand, { status, types }, { page, limit }),
190
+ fetchMetadata(brand, 'recent')
191
+ ])
192
+
170
193
  return {
171
194
  type: TabResponseType.CATALOG,
172
195
  data: recentContentIds,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -668,6 +668,25 @@ export async function fetchUserPracticeNotes(date) {
668
668
  return await fetchHandler(url, 'GET', null)
669
669
  }
670
670
 
671
+ export async function fetchRecent(brand, { status, types } = {}, {
672
+ page = 1,
673
+ limit = 10
674
+ } = {}) {
675
+ const query = new URLSearchParams()
676
+ query.append('brand', brand)
677
+ if (status) query.append('status', status)
678
+ if (types) {
679
+ types.forEach((type) => query.append('types[]', type))
680
+ }
681
+
682
+ query.append('page', page)
683
+ query.append('limit', limit)
684
+
685
+ const url = `/api/content-org/v1/user/recent?${query.toString()}`
686
+ const response = await fetchHandler(url, 'GET', null)
687
+ return response ? response.result : []
688
+ }
689
+
671
690
  /**
672
691
  * Get the id and slug of last interacted child. Only valid for certain content types
673
692
  *
File without changes
@@ -19,6 +19,7 @@ import {
19
19
  getFieldsForContentTypeWithFilteredChildren,
20
20
  getChildFieldsForContentType,
21
21
  SONG_TYPES,
22
+ recentTypes
22
23
  } from '../contentTypeConfig.js'
23
24
  import {fetchSimilarItems, recommendations} from './recommendations.js'
24
25
  import { processMetadata, typeWithSortOrder } from '../contentMetaData.js'
@@ -2051,10 +2052,10 @@ async function buildQuery(
2051
2052
  function buildEntityAndTotalQuery(
2052
2053
  filter = '',
2053
2054
  fields = '...',
2054
- { sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false, withoutPagination = false }
2055
+ { sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
2055
2056
  ) {
2056
2057
  const sortString = sortOrder ? ` | order(${sortOrder})` : ''
2057
- const countString = isSingle ? '[0...1]' : (withoutPagination ? ``: `[${start}...${end}]`)
2058
+ const countString = isSingle ? '[0...1]' : `[${start}...${end}]`
2058
2059
  const query = `{
2059
2060
  "entity": *[${filter}] ${sortString}${countString}
2060
2061
  {
@@ -2168,9 +2169,7 @@ export async function fetchTabData(
2168
2169
  page = 1,
2169
2170
  limit = 10,
2170
2171
  sort = '-published_on',
2171
- includedFields = [],
2172
- progressIds = undefined,
2173
- progress = 'all',
2172
+ includedFields = []
2174
2173
  } = {}
2175
2174
  ) {
2176
2175
  const start = (page - 1) * limit
@@ -2181,23 +2180,6 @@ export async function fetchTabData(
2181
2180
 
2182
2181
  let sortOrder = getSortOrder(sort, brand, '')
2183
2182
 
2184
- switch (progress) {
2185
- case 'recent':
2186
- progressIds = await getAllStartedOrCompleted({ brand, onlyIds: true });
2187
- sortOrder = null;
2188
- break;
2189
- case 'incomplete':
2190
- progressIds = await getAllStarted();
2191
- sortOrder = null;
2192
- break;
2193
- case 'completed':
2194
- progressIds = await getAllCompleted();
2195
- sortOrder = null;
2196
- break;
2197
- }
2198
-
2199
- // limits the results to supplied progressIds for started & completed filters
2200
- const progressFilter = await getProgressFilter(progress, progressIds)
2201
2183
  const fieldsString = getFieldsForContentType('tab-data');
2202
2184
  const now = getSanityDate(new Date())
2203
2185
 
@@ -2206,7 +2188,7 @@ export async function fetchTabData(
2206
2188
  let entityFieldsString = ''
2207
2189
  let filter = ''
2208
2190
 
2209
- filter = `brand == "${brand}" ${includedFieldsFilter} ${progressFilter}`
2191
+ filter = `brand == "${brand}" ${includedFieldsFilter}`
2210
2192
  const childrenFilter = await new FilterBuilder(``, { isChildrenFilter: true }).buildFilter()
2211
2193
  const lessonCountFilter = await new FilterBuilder(`_id in ^.child[]._ref`).buildFilter()
2212
2194
  entityFieldsString =
@@ -2231,36 +2213,9 @@ export async function fetchTabData(
2231
2213
 
2232
2214
  let results = await fetchSanity(query, true);
2233
2215
 
2234
- if (['recent', 'incomplete', 'completed'].includes(progress) && results.entity.length > 1) {
2235
- const orderMap = new Map(progressIds.map((id, index) => [id, index]))
2236
- results.entity = results.entity
2237
- .sort((a, b) => {
2238
- const aIdx = orderMap.get(a.id) ?? Number.MAX_SAFE_INTEGER;
2239
- const bIdx = orderMap.get(b.id) ?? Number.MAX_SAFE_INTEGER;
2240
- return aIdx - bIdx || new Date(b.published_on) - new Date(a.published_on);
2241
- })
2242
- .slice(start, end);
2243
- }
2244
-
2245
2216
  return results;
2246
2217
  }
2247
2218
 
2248
- export async function fetchRecent(
2249
- brand,
2250
- pageName,
2251
- { page = 1, limit = 10, sort = '-published_on', includedFields = [], progress = 'recent' } = {}
2252
- ) {
2253
- const mergedIncludedFields = [...includedFields, `tab,all`]
2254
- const results = await fetchTabData(brand, pageName, {
2255
- page,
2256
- limit,
2257
- sort,
2258
- includedFields: mergedIncludedFields,
2259
- progress: progress.toLowerCase(),
2260
- })
2261
- return results.entity
2262
- }
2263
-
2264
2219
  export async function fetchScheduledAndNewReleases(
2265
2220
  brand,
2266
2221
  { page = 1, limit = 20, sort = '-published_on' } = {}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -15,7 +15,6 @@ import {
15
15
  } from '../src/services/contentProgress'
16
16
  import { initializeTestService } from './initializeTests'
17
17
  import {getLessonContentRows, postContentComplete} from '../src'
18
- import {fetchRecent} from "../src/services/sanity";
19
18
  import {getRecent, getTabResults} from "../src/services/content";
20
19
  import {individualLessonsTypes, playAlongLessonTypes, transcriptionsLessonTypes, tutorialsLessonTypes} from "../src/contentTypeConfig";
21
20
 
@@ -258,21 +257,21 @@ describe('contentProgressDataContext', function () {
258
257
  //
259
258
  // });
260
259
  test('getRecentLessons', async () => {
261
- let result = await getRecent('drumeo','lessons', 'all',{page:1, limit:10})
260
+ let result = await getRecent('drumeo', {})
262
261
  console.log(result);
263
262
  expect(result.data[0].id).toStrictEqual(412986)
264
263
  expect(individualLessonsTypes).toContain(result.data[0].type)
265
264
  })
266
265
 
267
266
  test('getRecentLessons-Incomplete', async () => {
268
- let result = await getRecent('drumeo','lessons','Incomplete')
267
+ let result = await getRecent('drumeo', {status: 'incomplete'})
269
268
  console.log(result);
270
269
  expect(result.data[0].id).toStrictEqual(407665)
271
270
  expect(individualLessonsTypes).toContain(result.data[0].type)
272
271
  })
273
272
 
274
273
  test('getRecentLessons-Completed', async () => {
275
- let result = await getRecent('drumeo','lessons','Completed')
274
+ let result = await getRecent('drumeo', {status: 'completed'})
276
275
  console.log(result);
277
276
  expect(result.data[0].id).toStrictEqual(412986)
278
277
  expect(individualLessonsTypes).toContain(result.data[0].type)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/test/log.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/.yarnrc.yml DELETED
@@ -1 +0,0 @@
1
- nodeLinker: node-modules