musora-content-services 1.3.3 → 1.3.7

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 (70) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/.prettierignore +0 -0
  3. package/.prettierrc +0 -0
  4. package/CHANGELOG.md +8 -0
  5. package/README.md +0 -0
  6. package/babel.config.cjs +0 -0
  7. package/docs/config.js.html +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  26. package/docs/index.html +0 -0
  27. package/docs/module-Config.html +0 -0
  28. package/docs/module-Railcontent-Services.html +0 -0
  29. package/docs/module-Sanity-Services.html +0 -0
  30. package/docs/railcontent.js.html +0 -0
  31. package/docs/sanity.js.html +0 -0
  32. package/docs/scripts/collapse.js +0 -0
  33. package/docs/scripts/commonNav.js +0 -0
  34. package/docs/scripts/linenumber.js +0 -0
  35. package/docs/scripts/nav.js +0 -0
  36. package/docs/scripts/polyfill.js +0 -0
  37. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  38. package/docs/scripts/prettify/lang-css.js +0 -0
  39. package/docs/scripts/prettify/prettify.js +0 -0
  40. package/docs/scripts/search.js +0 -0
  41. package/docs/styles/jsdoc.css +0 -0
  42. package/docs/styles/prettify.css +0 -0
  43. package/jest.config.js +0 -0
  44. package/jsdoc.json +0 -0
  45. package/package.json +1 -1
  46. package/src/contentMetaData.js +90 -0
  47. package/src/contentTypeConfig.js +24 -0
  48. package/src/filterBuilder.js +0 -0
  49. package/src/index.d.ts +250 -227
  50. package/src/index.js +249 -226
  51. package/src/services/config.js +0 -0
  52. package/src/services/contentLikes.js +0 -0
  53. package/src/services/contentProgress.js +0 -0
  54. package/src/services/dataContext.js +0 -0
  55. package/src/services/lastUpdated.js +0 -0
  56. package/src/services/railcontent.js +1 -1
  57. package/src/services/sanity.js +112 -10
  58. package/src/services/userPermissions.js +0 -0
  59. package/test/contentLikes.test.js +0 -0
  60. package/test/contentProgress.test.js +0 -0
  61. package/test/initializeTests.js +0 -0
  62. package/test/lastUpdated.test.js +0 -0
  63. package/test/live/contentProgressLive.test.js +0 -0
  64. package/test/live/railcontentLive.test.js +0 -0
  65. package/test/localStorageMock.js +0 -0
  66. package/test/log.js +0 -0
  67. package/test/sanityQueryService.test.js +23 -0
  68. package/test/userPermissions.test.js +0 -0
  69. package/tools/generate-index.cjs +0 -0
  70. package/.yarnrc.yml +0 -1
package/src/index.js CHANGED
@@ -1,238 +1,261 @@
1
1
  /*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
2
2
 
3
- import { globalConfig, initializeService } from './services/config.js'
3
+ import {
4
+ globalConfig,
5
+ initializeService
6
+ } from './services/config.js';
4
7
 
5
- import { isContentLiked, likeContent, unlikeContent } from './services/contentLikes.js'
8
+ import {
9
+ isContentLiked,
10
+ likeContent,
11
+ unlikeContent
12
+ } from './services/contentLikes.js';
6
13
 
7
14
  import {
8
- assignmentStatusCompleted,
9
- assignmentStatusReset,
10
- contentStatusCompleted,
11
- contentStatusReset,
12
- getAllCompleted,
13
- getAllStarted,
14
- getAllStartedOrCompleted,
15
- getProgressPercentage,
16
- getProgressPercentageByIds,
17
- getProgressState,
18
- getProgressStateByIds,
19
- getResumeTimeSeconds,
20
- recordWatchSession,
21
- } from './services/contentProgress.js'
15
+ assignmentStatusCompleted,
16
+ assignmentStatusReset,
17
+ contentStatusCompleted,
18
+ contentStatusReset,
19
+ getAllCompleted,
20
+ getAllStarted,
21
+ getAllStartedOrCompleted,
22
+ getProgressPercentage,
23
+ getProgressPercentageByIds,
24
+ getProgressState,
25
+ getProgressStateByIds,
26
+ getResumeTimeSeconds,
27
+ recordWatchSession
28
+ } from './services/contentProgress.js';
22
29
 
23
30
  import {
24
- addItemToPlaylist,
25
- countAssignmentsAndLessons,
26
- createPlaylist,
27
- deletePlaylist,
28
- deletePlaylistItem,
29
- deletePlaylistLike,
30
- duplicatePlaylist,
31
- fetchAllCompletedStates,
32
- fetchCarouselCardData,
33
- fetchChallengeIndexMetadata,
34
- fetchChallengeLessonData,
35
- fetchChallengeMetadata,
36
- fetchChallengeUserActiveChallenges,
37
- fetchCompletedChallenges,
38
- fetchCompletedContent,
39
- fetchCompletedState,
40
- fetchContentInProgress,
41
- fetchContentPageUserData,
42
- fetchContentProgress,
43
- fetchHandler,
44
- fetchNextContentDataForParent,
45
- fetchOwnedChallenges,
46
- fetchPinnedPlaylists,
47
- fetchPlaylist,
48
- fetchPlaylistItem,
49
- fetchPlaylistItems,
50
- fetchSongsInProgress,
51
- fetchUserAward,
52
- fetchUserBadges,
53
- fetchUserChallengeProgress,
54
- fetchUserLikes,
55
- fetchUserPermissionsData,
56
- fetchUserPlaylists,
57
- likePlaylist,
58
- pinPlaylist,
59
- playback,
60
- postChallengesCommunityNotification,
61
- postChallengesCompleteLesson,
62
- postChallengesEnroll,
63
- postChallengesEnrollmentNotification,
64
- postChallengesHideCompletedBanner,
65
- postChallengesLeave,
66
- postChallengesSetStartDate,
67
- postChallengesSoloNotification,
68
- postChallengesUnlock,
69
- postContentCompleted,
70
- postContentLiked,
71
- postContentReset,
72
- postContentUnliked,
73
- postRecordWatchSession,
74
- reportPlaylist,
75
- setStudentViewForUser,
76
- unpinPlaylist,
77
- updatePlaylist,
78
- updatePlaylistItem,
79
- } from './services/railcontent.js'
31
+ setLastUpdatedTime,
32
+ wasLastUpdateOlderThanXSeconds
33
+ } from './services/lastUpdated.js';
80
34
 
81
35
  import {
82
- fetchAll,
83
- fetchAllFilterOptions,
84
- fetchAllPacks,
85
- fetchArtistLessons,
86
- fetchArtists,
87
- fetchByRailContentId,
88
- fetchByRailContentIds,
89
- fetchByReference,
90
- fetchChatAndLiveEnvent,
91
- fetchCoachLessons,
92
- fetchCommentModContentData,
93
- fetchFoundation,
94
- fetchGenreLessons,
95
- fetchHierarchy,
96
- fetchLessonContent,
97
- fetchLiveEvent,
98
- fetchMetadata,
99
- fetchMethod,
100
- fetchMethodChildren,
101
- fetchMethodChildrenIds,
102
- fetchMethodPreviousNextLesson,
103
- fetchNewReleases,
104
- fetchNextPreviousLesson,
105
- fetchPackAll,
106
- fetchPackData,
107
- fetchParentForDownload,
108
- fetchPlayAlongsCount,
109
- fetchRelatedLessons,
110
- fetchRelatedSongs,
111
- fetchSanity,
112
- fetchScheduledReleases,
113
- fetchShowsData,
114
- fetchSongArtistCount,
115
- fetchSongById,
116
- fetchTopLevelParentId,
117
- fetchUpcomingEvents,
118
- getSortOrder,
119
- jumpToContinueContent,
120
- } from './services/sanity.js'
36
+ addItemToPlaylist,
37
+ countAssignmentsAndLessons,
38
+ createPlaylist,
39
+ deletePlaylist,
40
+ deletePlaylistItem,
41
+ deletePlaylistLike,
42
+ duplicatePlaylist,
43
+ fetchAllCompletedStates,
44
+ fetchCarouselCardData,
45
+ fetchChallengeIndexMetadata,
46
+ fetchChallengeLessonData,
47
+ fetchChallengeMetadata,
48
+ fetchChallengeUserActiveChallenges,
49
+ fetchCompletedChallenges,
50
+ fetchCompletedContent,
51
+ fetchCompletedState,
52
+ fetchContentInProgress,
53
+ fetchContentPageUserData,
54
+ fetchContentProgress,
55
+ fetchHandler,
56
+ fetchNextContentDataForParent,
57
+ fetchOwnedChallenges,
58
+ fetchPinnedPlaylists,
59
+ fetchPlaylist,
60
+ fetchPlaylistItem,
61
+ fetchPlaylistItems,
62
+ fetchSongsInProgress,
63
+ fetchUserAward,
64
+ fetchUserBadges,
65
+ fetchUserChallengeProgress,
66
+ fetchUserLikes,
67
+ fetchUserPermissionsData,
68
+ fetchUserPlaylists,
69
+ likePlaylist,
70
+ pinPlaylist,
71
+ playback,
72
+ postChallengesCommunityNotification,
73
+ postChallengesCompleteLesson,
74
+ postChallengesEnroll,
75
+ postChallengesEnrollmentNotification,
76
+ postChallengesHideCompletedBanner,
77
+ postChallengesLeave,
78
+ postChallengesSetStartDate,
79
+ postChallengesSoloNotification,
80
+ postChallengesUnlock,
81
+ postContentCompleted,
82
+ postContentLiked,
83
+ postContentReset,
84
+ postContentUnliked,
85
+ postRecordWatchSession,
86
+ reportPlaylist,
87
+ setStudentViewForUser,
88
+ unpinPlaylist,
89
+ updatePlaylist,
90
+ updatePlaylistItem
91
+ } from './services/railcontent.js';
121
92
 
122
- import { fetchUserPermissions, reset } from './services/userPermissions.js'
93
+ import {
94
+ fetchAll,
95
+ fetchAllFilterOptions,
96
+ fetchAllPacks,
97
+ fetchArtistLessons,
98
+ fetchArtists,
99
+ fetchByRailContentId,
100
+ fetchByRailContentIds,
101
+ fetchByReference,
102
+ fetchChatAndLiveEnvent,
103
+ fetchCoachLessons,
104
+ fetchComingSoon,
105
+ fetchCommentModContentData,
106
+ fetchFoundation,
107
+ fetchGenreLessons,
108
+ fetchHierarchy,
109
+ fetchLeaving,
110
+ fetchLessonContent,
111
+ fetchLiveEvent,
112
+ fetchMetadata,
113
+ fetchMethod,
114
+ fetchMethodChildren,
115
+ fetchMethodChildrenIds,
116
+ fetchMethodPreviousNextLesson,
117
+ fetchNewReleases,
118
+ fetchNextPreviousLesson,
119
+ fetchPackAll,
120
+ fetchPackData,
121
+ fetchParentForDownload,
122
+ fetchPlayAlongsCount,
123
+ fetchRelatedLessons,
124
+ fetchRelatedSongs,
125
+ fetchReturning,
126
+ fetchSanity,
127
+ fetchScheduledReleases,
128
+ fetchShowsData,
129
+ fetchSongArtistCount,
130
+ fetchSongById,
131
+ fetchTopLevelParentId,
132
+ fetchUpcomingEvents,
133
+ getSortOrder,
134
+ jumpToContinueContent
135
+ } from './services/sanity.js';
136
+
137
+ import {
138
+ fetchUserPermissions,
139
+ reset
140
+ } from './services/userPermissions.js';
123
141
 
124
142
  export {
125
- addItemToPlaylist,
126
- assignmentStatusCompleted,
127
- assignmentStatusReset,
128
- contentStatusCompleted,
129
- contentStatusReset,
130
- countAssignmentsAndLessons,
131
- createPlaylist,
132
- deletePlaylist,
133
- deletePlaylistItem,
134
- deletePlaylistLike,
135
- duplicatePlaylist,
136
- fetchAll,
137
- fetchAllCompletedStates,
138
- fetchAllFilterOptions,
139
- fetchAllPacks,
140
- fetchArtistLessons,
141
- fetchArtists,
142
- fetchByRailContentId,
143
- fetchByRailContentIds,
144
- fetchByReference,
145
- fetchCarouselCardData,
146
- fetchChallengeIndexMetadata,
147
- fetchChallengeLessonData,
148
- fetchChallengeMetadata,
149
- fetchChallengeUserActiveChallenges,
150
- fetchChatAndLiveEnvent,
151
- fetchCoachLessons,
152
- fetchCommentModContentData,
153
- fetchCompletedChallenges,
154
- fetchCompletedContent,
155
- fetchCompletedState,
156
- fetchContentInProgress,
157
- fetchContentPageUserData,
158
- fetchContentProgress,
159
- fetchFoundation,
160
- fetchGenreLessons,
161
- fetchHandler,
162
- fetchHierarchy,
163
- fetchLessonContent,
164
- fetchLiveEvent,
165
- fetchMetadata,
166
- fetchMethod,
167
- fetchMethodChildren,
168
- fetchMethodChildrenIds,
169
- fetchMethodPreviousNextLesson,
170
- fetchNewReleases,
171
- fetchNextContentDataForParent,
172
- fetchNextPreviousLesson,
173
- fetchOwnedChallenges,
174
- fetchPackAll,
175
- fetchPackData,
176
- fetchParentForDownload,
177
- fetchPinnedPlaylists,
178
- fetchPlayAlongsCount,
179
- fetchPlaylist,
180
- fetchPlaylistItem,
181
- fetchPlaylistItems,
182
- fetchRelatedLessons,
183
- fetchRelatedSongs,
184
- fetchSanity,
185
- fetchScheduledReleases,
186
- fetchShowsData,
187
- fetchSongArtistCount,
188
- fetchSongById,
189
- fetchSongsInProgress,
190
- fetchTopLevelParentId,
191
- fetchUpcomingEvents,
192
- fetchUserAward,
193
- fetchUserBadges,
194
- fetchUserChallengeProgress,
195
- fetchUserLikes,
196
- fetchUserPermissions,
197
- fetchUserPermissionsData,
198
- fetchUserPlaylists,
199
- getAllCompleted,
200
- getAllStarted,
201
- getAllStartedOrCompleted,
202
- getProgressPercentage,
203
- getProgressPercentageByIds,
204
- getProgressState,
205
- getProgressStateByIds,
206
- getResumeTimeSeconds,
207
- getSortOrder,
208
- globalConfig,
209
- initializeService,
210
- isContentLiked,
211
- jumpToContinueContent,
212
- likeContent,
213
- likePlaylist,
214
- pinPlaylist,
215
- playback,
216
- postChallengesCommunityNotification,
217
- postChallengesCompleteLesson,
218
- postChallengesEnroll,
219
- postChallengesEnrollmentNotification,
220
- postChallengesHideCompletedBanner,
221
- postChallengesLeave,
222
- postChallengesSetStartDate,
223
- postChallengesSoloNotification,
224
- postChallengesUnlock,
225
- postContentCompleted,
226
- postContentLiked,
227
- postContentReset,
228
- postContentUnliked,
229
- postRecordWatchSession,
230
- recordWatchSession,
231
- reportPlaylist,
232
- reset,
233
- setStudentViewForUser,
234
- unlikeContent,
235
- unpinPlaylist,
236
- updatePlaylist,
237
- updatePlaylistItem,
238
- }
143
+ addItemToPlaylist,
144
+ assignmentStatusCompleted,
145
+ assignmentStatusReset,
146
+ contentStatusCompleted,
147
+ contentStatusReset,
148
+ countAssignmentsAndLessons,
149
+ createPlaylist,
150
+ deletePlaylist,
151
+ deletePlaylistItem,
152
+ deletePlaylistLike,
153
+ duplicatePlaylist,
154
+ fetchAll,
155
+ fetchAllCompletedStates,
156
+ fetchAllFilterOptions,
157
+ fetchAllPacks,
158
+ fetchArtistLessons,
159
+ fetchArtists,
160
+ fetchByRailContentId,
161
+ fetchByRailContentIds,
162
+ fetchByReference,
163
+ fetchCarouselCardData,
164
+ fetchChallengeIndexMetadata,
165
+ fetchChallengeLessonData,
166
+ fetchChallengeMetadata,
167
+ fetchChallengeUserActiveChallenges,
168
+ fetchChatAndLiveEnvent,
169
+ fetchCoachLessons,
170
+ fetchComingSoon,
171
+ fetchCommentModContentData,
172
+ fetchCompletedChallenges,
173
+ fetchCompletedContent,
174
+ fetchCompletedState,
175
+ fetchContentInProgress,
176
+ fetchContentPageUserData,
177
+ fetchContentProgress,
178
+ fetchFoundation,
179
+ fetchGenreLessons,
180
+ fetchHandler,
181
+ fetchHierarchy,
182
+ fetchLeaving,
183
+ fetchLessonContent,
184
+ fetchLiveEvent,
185
+ fetchMetadata,
186
+ fetchMethod,
187
+ fetchMethodChildren,
188
+ fetchMethodChildrenIds,
189
+ fetchMethodPreviousNextLesson,
190
+ fetchNewReleases,
191
+ fetchNextContentDataForParent,
192
+ fetchNextPreviousLesson,
193
+ fetchOwnedChallenges,
194
+ fetchPackAll,
195
+ fetchPackData,
196
+ fetchParentForDownload,
197
+ fetchPinnedPlaylists,
198
+ fetchPlayAlongsCount,
199
+ fetchPlaylist,
200
+ fetchPlaylistItem,
201
+ fetchPlaylistItems,
202
+ fetchRelatedLessons,
203
+ fetchRelatedSongs,
204
+ fetchReturning,
205
+ fetchSanity,
206
+ fetchScheduledReleases,
207
+ fetchShowsData,
208
+ fetchSongArtistCount,
209
+ fetchSongById,
210
+ fetchSongsInProgress,
211
+ fetchTopLevelParentId,
212
+ fetchUpcomingEvents,
213
+ fetchUserAward,
214
+ fetchUserBadges,
215
+ fetchUserChallengeProgress,
216
+ fetchUserLikes,
217
+ fetchUserPermissions,
218
+ fetchUserPermissionsData,
219
+ fetchUserPlaylists,
220
+ getAllCompleted,
221
+ getAllStarted,
222
+ getAllStartedOrCompleted,
223
+ getProgressPercentage,
224
+ getProgressPercentageByIds,
225
+ getProgressState,
226
+ getProgressStateByIds,
227
+ getResumeTimeSeconds,
228
+ getSortOrder,
229
+ globalConfig,
230
+ initializeService,
231
+ isContentLiked,
232
+ jumpToContinueContent,
233
+ likeContent,
234
+ likePlaylist,
235
+ pinPlaylist,
236
+ playback,
237
+ postChallengesCommunityNotification,
238
+ postChallengesCompleteLesson,
239
+ postChallengesEnroll,
240
+ postChallengesEnrollmentNotification,
241
+ postChallengesHideCompletedBanner,
242
+ postChallengesLeave,
243
+ postChallengesSetStartDate,
244
+ postChallengesSoloNotification,
245
+ postChallengesUnlock,
246
+ postContentCompleted,
247
+ postContentLiked,
248
+ postContentReset,
249
+ postContentUnliked,
250
+ postRecordWatchSession,
251
+ recordWatchSession,
252
+ reportPlaylist,
253
+ reset,
254
+ setLastUpdatedTime,
255
+ setStudentViewForUser,
256
+ unlikeContent,
257
+ unpinPlaylist,
258
+ updatePlaylist,
259
+ updatePlaylistItem,
260
+ wasLastUpdateOlderThanXSeconds,
261
+ };
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -493,7 +493,7 @@ export async function fetchChallengeUserActiveChallenges(brand = null) {
493
493
  */
494
494
  export async function fetchCarouselCardData(brand = null) {
495
495
  const brandParam = brand ? `?brand=${brand}` : ''
496
- let url = `/api/v1/content/carousel${brandParam}`
496
+ let url = `/api/v2/content/carousel${brandParam}`
497
497
  return await fetchHandler(url, 'get')
498
498
  }
499
499
 
@@ -15,6 +15,7 @@ import {
15
15
  showsTypes,
16
16
  getNewReleasesTypes,
17
17
  coachLessonsTypes,
18
+ getChildFieldsForContentType,
18
19
  } from '../contentTypeConfig.js'
19
20
 
20
21
  import { processMetadata, typeWithSortOrder } from '../contentMetaData.js'
@@ -64,6 +65,112 @@ export async function fetchSongById(documentId) {
64
65
  return fetchSanity(query, false)
65
66
  }
66
67
 
68
+ /**
69
+ * fetches from Sanity all content marked for removal next quarter
70
+ *
71
+ * @string brand
72
+ * @number pageNumber
73
+ * @number contentPerPage
74
+ * @returns {Promise<Object|null>}
75
+ */
76
+ export async function fetchLeaving(
77
+ brand,
78
+ { pageNumber = 1, contentPerPage = 20 } = {}) {
79
+ const nextQuarter = getNextAndPreviousQuarterDates()['next'];
80
+ const filterString = `brand == '${brand}' && quarter_removed == '${nextQuarter}'`
81
+ const startEndOrder = getQueryFromPage(pageNumber, contentPerPage);
82
+ const sortOrder = {sortOrder: "published_on desc, id desc", start: startEndOrder['start'], end: startEndOrder['end']};
83
+ const query = await buildQuery(filterString, {pullFutureContent: false, availableContentStatuses: ["published"]}, getFieldsForContentType(), sortOrder);
84
+ return fetchSanity(query, true);
85
+ }
86
+
87
+ /**
88
+ * fetches from Sanity all content marked for return next quarter
89
+ *
90
+ * @string brand
91
+ * @number pageNumber
92
+ * @number contentPerPage
93
+ * @returns {Promise<Object|null>}
94
+ */
95
+ export async function fetchReturning(
96
+ brand,
97
+ { pageNumber = 1, contentPerPage = 20 } = {}) {
98
+ const nextQuarter = getNextAndPreviousQuarterDates()['next'];
99
+ const filterString = `brand == '${brand}' && quarter_published == '${nextQuarter}'`;
100
+ const startEndOrder = getQueryFromPage(pageNumber, contentPerPage);
101
+ const sortOrder = {sortOrder: "published_on desc, id desc", start: startEndOrder['start'], end: startEndOrder['end']};
102
+ const query = await buildQuery(filterString, {pullFutureContent: true, availableContentStatuses: ["draft"]}, getFieldsForContentType(), sortOrder);
103
+
104
+ return fetchSanity(query, true);
105
+ }
106
+
107
+ /**
108
+ * fetches from Sanity all songs coming soon (new) next quarter
109
+ *
110
+ * @string brand
111
+ * @number pageNumber
112
+ * @number contentPerPage
113
+ * @returns {Promise<Object|null>}
114
+ */
115
+ export async function fetchComingSoon(
116
+ brand,
117
+ { pageNumber = 1, contentPerPage = 20 } = {}) {
118
+ const filterString = `brand == '${brand}' && _type == 'song'`;
119
+ const startEndOrder = getQueryFromPage(pageNumber, contentPerPage);
120
+ const sortOrder = {sortOrder: "published_on desc, id desc", start: startEndOrder['start'], end: startEndOrder['end']};
121
+ const query = await buildQuery(filterString, {getFutureContentOnly: true}, getFieldsForContentType(), sortOrder);
122
+ return fetchSanity(query, true);
123
+ }
124
+
125
+ /**
126
+ *
127
+ * @number page
128
+ * @returns {number[]}
129
+ */
130
+ function getQueryFromPage(pageNumber, contentPerPage) {
131
+ const start = contentPerPage*(pageNumber-1);
132
+ const end = contentPerPage*pageNumber;
133
+ let result = [];
134
+ result['start'] = start;
135
+ result['end'] = end;
136
+ return result;
137
+ }
138
+
139
+ /**
140
+ * returns array of next and previous quarter dates as strings
141
+ *
142
+ * @returns {*[]}
143
+ */
144
+ function getNextAndPreviousQuarterDates() {
145
+ const january = 1;
146
+ const april = 4;
147
+ const july = 7;
148
+ const october = 10;
149
+ const month = new Date().getMonth();
150
+ let year = new Date().getFullYear();
151
+ let nextQuarter = '';
152
+ let prevQuarter = '';
153
+ if (month < april) {
154
+ nextQuarter = `${year}-0${april}-01`;
155
+ prevQuarter = `${year}-0${january}-01`;
156
+ } else if (month < july) {
157
+ nextQuarter = `${year}-0${july}-01`;
158
+ prevQuarter = `${year}-0${april}-01`;
159
+ } else if (month < october) {
160
+ nextQuarter = `${year}-${october}-01`;
161
+ prevQuarter = `${year}-0${july}-01`;
162
+ } else {
163
+ prevQuarter = `${year}-${october}-01`;
164
+ year++;
165
+ nextQuarter = `${year}-0${january}-01`;
166
+ }
167
+
168
+ let result = [];
169
+ result['next'] = nextQuarter;
170
+ result['previous'] = prevQuarter;
171
+ return result;
172
+ }
173
+
67
174
  /**
68
175
  * Fetch all artists with lessons available for a specific brand.
69
176
  *
@@ -341,16 +448,11 @@ export async function fetchScheduledReleases(brand, { page = 1, limit = 10 }) {
341
448
  */
342
449
  export async function fetchByRailContentId(id, contentType) {
343
450
  const fields = getFieldsForContentType(contentType)
451
+ const childFields = getChildFieldsForContentType(contentType)
344
452
  const childrenFilter = await new FilterBuilder(``, { isChildrenFilter: true }).buildFilter()
345
453
  const entityFieldsString = ` ${fields}
346
454
  'child_count': coalesce(count(child[${childrenFilter}]->), 0) ,
347
- "lessons": child[${childrenFilter}]->{
348
- "id": railcontent_id,
349
- title,
350
- "image": thumbnail.asset->url,
351
- "instructors": instructor[]->name,
352
- length_in_seconds,
353
- },
455
+ "lessons": child[${childrenFilter}]->{${childFields}},
354
456
  'length_in_seconds': coalesce(
355
457
  math::sum(
356
458
  select(
@@ -1855,7 +1957,7 @@ function checkSanityConfig(config) {
1855
1957
  function buildRawQuery(
1856
1958
  filter = '',
1857
1959
  fields = '...',
1858
- { sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
1960
+ { sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false}
1859
1961
  ) {
1860
1962
  const sortString = sortOrder ? `order(${sortOrder})` : ''
1861
1963
  const countString = isSingle ? '[0...1]' : `[${start}...${end}]`
@@ -1869,10 +1971,10 @@ async function buildQuery(
1869
1971
  baseFilter = '',
1870
1972
  filterParams = { pullFutureContent: false },
1871
1973
  fields = '...',
1872
- { sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
1974
+ { sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false}
1873
1975
  ) {
1874
1976
  const filter = await new FilterBuilder(baseFilter, filterParams).buildFilter()
1875
- return buildRawQuery(filter, fields, { sortOrder, start, end, isSingle })
1977
+ return buildRawQuery(filter, fields, { sortOrder, start, end, isSingle})
1876
1978
  }
1877
1979
 
1878
1980
  function buildEntityAndTotalQuery(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes