musora-content-services 1.5.0 → 1.6.0
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 +7 -0
- package/docs/algolia.js.html +137 -0
- package/docs/config.js.html +29 -5
- package/docs/index.html +2 -2
- package/docs/module-Config.html +108 -7
- package/docs/module-Railcontent-Services.html +551 -31
- package/docs/module-Sanity-Services.html +1999 -73
- package/docs/module-Search-Engine-Services.html +354 -0
- package/docs/railcontent.js.html +41 -4
- package/docs/sanity.js.html +265 -82
- package/jsdoc.json +1 -0
- package/package.json +4 -2
- package/src/index.d.ts +5 -0
- package/src/index.js +5 -0
- package/src/services/algolia.js +64 -0
- package/src/services/config.js +5 -1
package/docs/sanity.js.html
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#.initializeService">initializeService</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCarouselCardData">fetchCarouselCardData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeUserActiveChallenges">fetchChallengeUserActiveChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedChallenges">fetchCompletedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchNextContentDataForParent">fetchNextContentDataForParent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchOwnedChallenges">fetchOwnedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPinnedPlaylists">fetchPinnedPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserBadges">fetchUserBadges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserPlaylists">fetchUserPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.pinPlaylist">pinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCompleteLesson">postChallengesCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesHideCompletedBanner">postChallengesHideCompletedBanner</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSoloNotification">postChallengesSoloNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.reportPlaylist">reportPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.setStudentViewForUser">setStudentViewForUser</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unpinPlaylist">unpinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchComingSoon">fetchComingSoon</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLeaving">fetchLeaving</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchReturning">fetchReturning</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.jumpToContinueContent">jumpToContinueContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getNextAndPreviousQuarterDates">getNextAndPreviousQuarterDates</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getQueryFromPage">getQueryFromPage</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li></ul>
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#.initializeService">initializeService</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCarouselCardData">fetchCarouselCardData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeUserActiveChallenges">fetchChallengeUserActiveChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCommentRelies">fetchCommentRelies</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchComments">fetchComments</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedChallenges">fetchCompletedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchNextContentDataForParent">fetchNextContentDataForParent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchOwnedChallenges">fetchOwnedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPinnedPlaylists">fetchPinnedPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchTopComment">fetchTopComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserBadges">fetchUserBadges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserPlaylists">fetchUserPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.pinPlaylist">pinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCompleteLesson">postChallengesCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesHideCompletedBanner">postChallengesHideCompletedBanner</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSoloNotification">postChallengesSoloNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.reportPlaylist">reportPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.setStudentViewForUser">setStudentViewForUser</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unpinPlaylist">unpinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchComingSoon">fetchComingSoon</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLeaving">fetchLeaving</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedTutorials">fetchRelatedTutorials</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchReturning">fetchReturning</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.jumpToContinueContent">jumpToContinueContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#~buildQueryForFetch">buildQueryForFetch</a></li><li data-type='method'><a href="module-Sanity-Services.html#~buildRelatedLessonsQuery">buildRelatedLessonsQuery</a></li><li data-type='method'><a href="module-Sanity-Services.html#~buildSubQueryForFetch">buildSubQueryForFetch</a></li><li data-type='method'><a href="module-Sanity-Services.html#~fetchParentContentGenres">fetchParentContentGenres</a></li><li data-type='method'><a href="module-Sanity-Services.html#~fetchParentData">fetchParentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#~fetchRelatedLessonsSectionData">fetchRelatedLessonsSectionData</a></li><li data-type='method'><a href="module-Sanity-Services.html#~formatForResponse">formatForResponse</a></li><li data-type='method'><a href="module-Sanity-Services.html#~formatGenresToString">formatGenresToString</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getCurrentContentDataForQuery">getCurrentContentDataForQuery</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getNextAndPreviousQuarterDates">getNextAndPreviousQuarterDates</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getQueryFromPage">getQueryFromPage</a></li><li data-type='method'><a href="module-Sanity-Services.html#~groupCurrentContentData">groupCurrentContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li><li><a href="module-Search-Engine-Services.html">Search-Engine-Services</a><ul class='methods'><li data-type='method'><a href="module-Search-Engine-Services.html#.sendAlgoliaClickEvent">sendAlgoliaClickEvent</a></li></ul></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -120,15 +120,22 @@ export async function fetchSongById(documentId) {
|
|
|
120
120
|
* @number contentPerPage
|
|
121
121
|
* @returns {Promise<Object|null>}
|
|
122
122
|
*/
|
|
123
|
-
export async function fetchLeaving(
|
|
124
|
-
|
|
125
|
-
{ pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
126
|
-
const nextQuarter = getNextAndPreviousQuarterDates()['next'];
|
|
123
|
+
export async function fetchLeaving(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
124
|
+
const nextQuarter = getNextAndPreviousQuarterDates()['next']
|
|
127
125
|
const filterString = `brand == '${brand}' && quarter_removed == '${nextQuarter}'`
|
|
128
|
-
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
129
|
-
const sortOrder = {
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
127
|
+
const sortOrder = {
|
|
128
|
+
sortOrder: 'published_on desc, id desc',
|
|
129
|
+
start: startEndOrder['start'],
|
|
130
|
+
end: startEndOrder['end'],
|
|
131
|
+
}
|
|
132
|
+
const query = await buildQuery(
|
|
133
|
+
filterString,
|
|
134
|
+
{ pullFutureContent: false, availableContentStatuses: ['published'] },
|
|
135
|
+
getFieldsForContentType(),
|
|
136
|
+
sortOrder
|
|
137
|
+
)
|
|
138
|
+
return fetchSanity(query, true)
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
/**
|
|
@@ -139,16 +146,23 @@ export async function fetchLeaving(
|
|
|
139
146
|
* @number contentPerPage
|
|
140
147
|
* @returns {Promise<Object|null>}
|
|
141
148
|
*/
|
|
142
|
-
export async function fetchReturning(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
export async function fetchReturning(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
150
|
+
const nextQuarter = getNextAndPreviousQuarterDates()['next']
|
|
151
|
+
const filterString = `brand == '${brand}' && quarter_published == '${nextQuarter}'`
|
|
152
|
+
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
153
|
+
const sortOrder = {
|
|
154
|
+
sortOrder: 'published_on desc, id desc',
|
|
155
|
+
start: startEndOrder['start'],
|
|
156
|
+
end: startEndOrder['end'],
|
|
157
|
+
}
|
|
158
|
+
const query = await buildQuery(
|
|
159
|
+
filterString,
|
|
160
|
+
{ pullFutureContent: true, availableContentStatuses: ['draft'] },
|
|
161
|
+
getFieldsForContentType('returning'),
|
|
162
|
+
sortOrder
|
|
163
|
+
)
|
|
150
164
|
|
|
151
|
-
return fetchSanity(query, true)
|
|
165
|
+
return fetchSanity(query, true)
|
|
152
166
|
}
|
|
153
167
|
|
|
154
168
|
/**
|
|
@@ -159,14 +173,21 @@ export async function fetchReturning(
|
|
|
159
173
|
* @number contentPerPage
|
|
160
174
|
* @returns {Promise<Object|null>}
|
|
161
175
|
*/
|
|
162
|
-
export async function fetchComingSoon(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
export async function fetchComingSoon(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
177
|
+
const filterString = `brand == '${brand}' && _type == 'song'`
|
|
178
|
+
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
179
|
+
const sortOrder = {
|
|
180
|
+
sortOrder: 'published_on desc, id desc',
|
|
181
|
+
start: startEndOrder['start'],
|
|
182
|
+
end: startEndOrder['end'],
|
|
183
|
+
}
|
|
184
|
+
const query = await buildQuery(
|
|
185
|
+
filterString,
|
|
186
|
+
{ getFutureContentOnly: true },
|
|
187
|
+
getFieldsForContentType(),
|
|
188
|
+
sortOrder
|
|
189
|
+
)
|
|
190
|
+
return fetchSanity(query, true)
|
|
170
191
|
}
|
|
171
192
|
|
|
172
193
|
/**
|
|
@@ -175,47 +196,47 @@ export async function fetchComingSoon(
|
|
|
175
196
|
* @returns {number[]}
|
|
176
197
|
*/
|
|
177
198
|
function getQueryFromPage(pageNumber, contentPerPage) {
|
|
178
|
-
const start = contentPerPage*(pageNumber-1)
|
|
179
|
-
const end = contentPerPage*pageNumber
|
|
180
|
-
let result = []
|
|
181
|
-
result['start'] = start
|
|
182
|
-
result['end'] = end
|
|
183
|
-
return result
|
|
199
|
+
const start = contentPerPage * (pageNumber - 1)
|
|
200
|
+
const end = contentPerPage * pageNumber
|
|
201
|
+
let result = []
|
|
202
|
+
result['start'] = start
|
|
203
|
+
result['end'] = end
|
|
204
|
+
return result
|
|
184
205
|
}
|
|
185
206
|
|
|
186
207
|
/**
|
|
187
208
|
* returns array of next and previous quarter dates as strings
|
|
188
209
|
*
|
|
189
|
-
* @returns {
|
|
210
|
+
* @returns {Array<any>}
|
|
190
211
|
*/
|
|
191
212
|
function getNextAndPreviousQuarterDates() {
|
|
192
|
-
const january = 1
|
|
193
|
-
const april = 4
|
|
194
|
-
const july = 7
|
|
195
|
-
const october = 10
|
|
196
|
-
const month = new Date().getMonth()
|
|
197
|
-
let year = new Date().getFullYear()
|
|
198
|
-
let nextQuarter = ''
|
|
199
|
-
let prevQuarter = ''
|
|
213
|
+
const january = 1
|
|
214
|
+
const april = 4
|
|
215
|
+
const july = 7
|
|
216
|
+
const october = 10
|
|
217
|
+
const month = new Date().getMonth()
|
|
218
|
+
let year = new Date().getFullYear()
|
|
219
|
+
let nextQuarter = ''
|
|
220
|
+
let prevQuarter = ''
|
|
200
221
|
if (month < april) {
|
|
201
|
-
nextQuarter = `${year}-0${april}-01
|
|
202
|
-
prevQuarter = `${year}-0${january}-01
|
|
222
|
+
nextQuarter = `${year}-0${april}-01`
|
|
223
|
+
prevQuarter = `${year}-0${january}-01`
|
|
203
224
|
} else if (month < july) {
|
|
204
|
-
nextQuarter = `${year}-0${july}-01
|
|
205
|
-
prevQuarter = `${year}-0${april}-01
|
|
225
|
+
nextQuarter = `${year}-0${july}-01`
|
|
226
|
+
prevQuarter = `${year}-0${april}-01`
|
|
206
227
|
} else if (month < october) {
|
|
207
|
-
nextQuarter = `${year}-${october}-01
|
|
208
|
-
prevQuarter = `${year}-0${july}-01
|
|
228
|
+
nextQuarter = `${year}-${october}-01`
|
|
229
|
+
prevQuarter = `${year}-0${july}-01`
|
|
209
230
|
} else {
|
|
210
|
-
prevQuarter = `${year}-${october}-01
|
|
211
|
-
year
|
|
212
|
-
nextQuarter = `${year}-0${january}-01
|
|
231
|
+
prevQuarter = `${year}-${october}-01`
|
|
232
|
+
year++
|
|
233
|
+
nextQuarter = `${year}-0${january}-01`
|
|
213
234
|
}
|
|
214
235
|
|
|
215
|
-
let result = []
|
|
216
|
-
result['next'] = nextQuarter
|
|
217
|
-
result['previous'] = prevQuarter
|
|
218
|
-
return result
|
|
236
|
+
let result = []
|
|
237
|
+
result['next'] = nextQuarter
|
|
238
|
+
result['previous'] = prevQuarter
|
|
239
|
+
return result
|
|
219
240
|
}
|
|
220
241
|
|
|
221
242
|
/**
|
|
@@ -249,8 +270,8 @@ export async function fetchArtists(brand) {
|
|
|
249
270
|
*/
|
|
250
271
|
export async function fetchSongArtistCount(brand) {
|
|
251
272
|
const filter = await new FilterBuilder(
|
|
252
|
-
|
|
253
|
-
|
|
273
|
+
`_type == "song" && brand == "${brand}" && references(^._id)`,
|
|
274
|
+
{ bypassPermissions: true }
|
|
254
275
|
).buildFilter()
|
|
255
276
|
const query = `
|
|
256
277
|
count(*[_type == "artist"]{
|
|
@@ -260,13 +281,13 @@ export async function fetchSongArtistCount(brand) {
|
|
|
260
281
|
return fetchSanity(query, true, { processNeedAccess: false })
|
|
261
282
|
}
|
|
262
283
|
|
|
263
|
-
export async function fetchPlayAlongsCount(
|
|
264
|
-
|
|
265
|
-
includedFields,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
284
|
+
export async function fetchPlayAlongsCount(
|
|
285
|
+
brand,
|
|
286
|
+
{ searchTerm, includedFields, progressIds, progress }
|
|
287
|
+
) {
|
|
288
|
+
const searchFilter = searchTerm
|
|
289
|
+
? `&& (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*" || name match "${searchTerm}*")`
|
|
290
|
+
: ''
|
|
270
291
|
|
|
271
292
|
// Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
|
|
272
293
|
const includedFieldsFilter = includedFields.length > 0 ? filtersToGroq(includedFields) : ''
|
|
@@ -302,6 +323,7 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
302
323
|
"published_on": published_on,
|
|
303
324
|
status,
|
|
304
325
|
"image": thumbnail.asset->url,
|
|
326
|
+
"permission_id": permission[]->railcontent_id,
|
|
305
327
|
"fields": [
|
|
306
328
|
{
|
|
307
329
|
"key": "title",
|
|
@@ -327,6 +349,7 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
327
349
|
"id": railcontent_id,
|
|
328
350
|
"url": web_url_path,
|
|
329
351
|
"published_on": published_on,
|
|
352
|
+
"permission_id": permission[]->railcontent_id,
|
|
330
353
|
status,
|
|
331
354
|
"fields": [
|
|
332
355
|
{
|
|
@@ -428,7 +451,8 @@ export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {})
|
|
|
428
451
|
published_on,
|
|
429
452
|
"type": _type,
|
|
430
453
|
web_url_path,
|
|
431
|
-
"permission_id": permission[]->railcontent_id
|
|
454
|
+
"permission_id": permission[]->railcontent_id,
|
|
455
|
+
event_calendar_unique_key`
|
|
432
456
|
const query = buildRawQuery(
|
|
433
457
|
`_type in ${typesString} && brand == '${brand}' && published_on > '${now}' && status == 'scheduled'`,
|
|
434
458
|
fields,
|
|
@@ -534,7 +558,7 @@ export async function fetchByRailContentId(id, contentType) {
|
|
|
534
558
|
*/
|
|
535
559
|
export async function fetchByRailContentIds(ids, contentType = undefined) {
|
|
536
560
|
if (!ids) {
|
|
537
|
-
return []
|
|
561
|
+
return []
|
|
538
562
|
}
|
|
539
563
|
const idsString = ids.join(',')
|
|
540
564
|
|
|
@@ -1288,7 +1312,7 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1288
1312
|
"coach_profile_image":thumbnail_url.asset->url
|
|
1289
1313
|
},
|
|
1290
1314
|
${assignmentsField}
|
|
1291
|
-
video,
|
|
1315
|
+
'video': coalesce(video[0], video),
|
|
1292
1316
|
length_in_seconds,
|
|
1293
1317
|
mp3_no_drums_no_click_url,
|
|
1294
1318
|
mp3_no_drums_yes_click_url,
|
|
@@ -1303,11 +1327,22 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1303
1327
|
"type": *[railcontent_id == ^.id][0]._type,
|
|
1304
1328
|
},
|
|
1305
1329
|
sort,
|
|
1306
|
-
xp
|
|
1330
|
+
xp,
|
|
1331
|
+
stbs,ds2stbs, bdsStbs`
|
|
1307
1332
|
const query = await buildQuery(`railcontent_id == ${railContentId}`, filterParams, fields, {
|
|
1308
1333
|
isSingle: true,
|
|
1309
1334
|
})
|
|
1310
|
-
|
|
1335
|
+
const chapterProcess = (result) => {
|
|
1336
|
+
const chapters = result.chapters ?? []
|
|
1337
|
+
if (chapters.length == 0) return result
|
|
1338
|
+
result.chapters = chapters.map((chapter, index) => ({
|
|
1339
|
+
...chapter,
|
|
1340
|
+
chapter_thumbnail_url: `https://musora-web-platform.s3.amazonaws.com/chapters/${result.brand}/Chapter${index + 1}.jpg`,
|
|
1341
|
+
}))
|
|
1342
|
+
return result
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
return fetchSanity(query, false, { customPostProcess: chapterProcess })
|
|
1311
1346
|
}
|
|
1312
1347
|
|
|
1313
1348
|
/**
|
|
@@ -1331,20 +1366,166 @@ export async function fetchRelatedLessons(railContentId, brand) {
|
|
|
1331
1366
|
).buildFilter()
|
|
1332
1367
|
const filterNeighbouringSiblings = await new FilterBuilder(`references(^._id)`).buildFilter()
|
|
1333
1368
|
const childrenFilter = await new FilterBuilder(``, { isChildrenFilter: true }).buildFilter()
|
|
1334
|
-
|
|
1335
|
-
const
|
|
1369
|
+
const queryFields = `_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type, "genre": genre[]->name`
|
|
1370
|
+
const queryFieldsWithSort = queryFields + ', sort'
|
|
1371
|
+
const query = `*[railcontent_id == ${railContentId} && brand == "${brand}"]{
|
|
1336
1372
|
_type, parent_type, railcontent_id,
|
|
1337
1373
|
"related_lessons" : array::unique([
|
|
1338
|
-
...(*[${filterNeighbouringSiblings}][0].child[${childrenFilter}]->{
|
|
1339
|
-
...(*[${filterSongSameArtist}]{
|
|
1340
|
-
...(*[${filterSongSameGenre}]{
|
|
1341
|
-
...(*[${filterSameTypeAndSortOrder}]{
|
|
1342
|
-
...(*[${filterSameType}]{
|
|
1374
|
+
...(*[${filterNeighbouringSiblings}][0].child[${childrenFilter}]->{${queryFields}}),
|
|
1375
|
+
...(*[${filterSongSameArtist}]{${queryFields}}|order(published_on desc, title asc)[0...10]),
|
|
1376
|
+
...(*[${filterSongSameGenre}]{${queryFields}}|order(published_on desc, title asc)[0...10]),
|
|
1377
|
+
...(*[${filterSameTypeAndSortOrder}]{${queryFieldsWithSort}}|order(sort asc, title asc)[0...10]),
|
|
1378
|
+
...(*[${filterSameType}]{${queryFields}}|order(published_on desc, title asc)[0...10])
|
|
1343
1379
|
,
|
|
1344
1380
|
])[0...10]}`
|
|
1345
1381
|
return fetchSanity(query, false)
|
|
1346
1382
|
}
|
|
1347
1383
|
|
|
1384
|
+
/**
|
|
1385
|
+
* fetch song tutorials related to a specific tutorial, by genre and difficulty.
|
|
1386
|
+
* @param {number} railContentId
|
|
1387
|
+
* @param {string} brand
|
|
1388
|
+
* @returns {Promise<Object|null>}
|
|
1389
|
+
*/
|
|
1390
|
+
export async function fetchRelatedTutorials(railContentId, brand) {
|
|
1391
|
+
const parentObject = await fetchParentData(railContentId, brand)
|
|
1392
|
+
const relatedLessonObject = await fetchRelatedLessonsSectionData(parentObject)
|
|
1393
|
+
return formatForResponse(parentObject, relatedLessonObject)
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* fetch data of parent content, and combine with some of current content
|
|
1398
|
+
* @param {number} railContentId
|
|
1399
|
+
* @param {string} brand
|
|
1400
|
+
* @returns {Promise<Object|null>}
|
|
1401
|
+
*/
|
|
1402
|
+
async function fetchParentData(railContentId, brand) {
|
|
1403
|
+
const parentQuery = buildQueryForFetch(railContentId, brand)
|
|
1404
|
+
return await fetchSanity(parentQuery, false)
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* build query for fetch of parent data
|
|
1409
|
+
* @param {number} railContentId
|
|
1410
|
+
* @param {string} brand
|
|
1411
|
+
* @returns {string}
|
|
1412
|
+
*/
|
|
1413
|
+
function buildQueryForFetch(railContentId, brand) {
|
|
1414
|
+
const projections = `railcontent_id, _type, parent_type, parent_content_data, difficulty_string, brand`
|
|
1415
|
+
return `*[railcontent_id == ${railContentId} && brand == "${brand}"]{${projections}}`
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* fetch related lessons content
|
|
1420
|
+
* @param {Object} currentContent
|
|
1421
|
+
* @returns {Promise<Object|null>}
|
|
1422
|
+
*/
|
|
1423
|
+
async function fetchRelatedLessonsSectionData(currentContent) {
|
|
1424
|
+
const query = await buildRelatedLessonsQuery(currentContent)
|
|
1425
|
+
return await fetchSanity(query, true)
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* build query for related lessons by content type
|
|
1430
|
+
* @param {Object} currentContent
|
|
1431
|
+
* @returns {Promise<string>}
|
|
1432
|
+
*/
|
|
1433
|
+
async function buildRelatedLessonsQuery(currentContent) {
|
|
1434
|
+
const defaultProjectionsAndSorting = `{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type,genre}|order(published_on desc, title asc)[0...10]`
|
|
1435
|
+
const currentContentData = await getCurrentContentDataForQuery(currentContent)
|
|
1436
|
+
const tutorialQuery = await buildSubQueryForFetch(
|
|
1437
|
+
currentContentData.parentType,
|
|
1438
|
+
currentContentData.brand,
|
|
1439
|
+
currentContentData.parentId,
|
|
1440
|
+
currentContentData.difficulty_string,
|
|
1441
|
+
currentContentData.genres
|
|
1442
|
+
)
|
|
1443
|
+
const quickTipQuery = await buildSubQueryForFetch(
|
|
1444
|
+
'quick-tips',
|
|
1445
|
+
currentContentData.brand,
|
|
1446
|
+
currentContentData.parentId,
|
|
1447
|
+
currentContentData.difficulty_string
|
|
1448
|
+
)
|
|
1449
|
+
const songQuery = await buildSubQueryForFetch(
|
|
1450
|
+
'song',
|
|
1451
|
+
currentContentData.brand,
|
|
1452
|
+
currentContentData.parentId,
|
|
1453
|
+
currentContentData.difficulty_string
|
|
1454
|
+
)
|
|
1455
|
+
return `[...*[${tutorialQuery}]${defaultProjectionsAndSorting}, ...*[${quickTipQuery}]${defaultProjectionsAndSorting}, ...*[${songQuery}]${defaultProjectionsAndSorting}, ]`
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* get data, primarily brand, for use in the related_lessons query
|
|
1460
|
+
* @param {Object} currentContent
|
|
1461
|
+
* @returns {Object}
|
|
1462
|
+
*/
|
|
1463
|
+
async function getCurrentContentDataForQuery(currentContent) {
|
|
1464
|
+
const currentContentData = groupCurrentContentData(currentContent)
|
|
1465
|
+
const genres = await fetchParentContentGenres(currentContentData)
|
|
1466
|
+
const genreString = formatGenresToString(genres)
|
|
1467
|
+
return { ...currentContentData, genres: genreString }
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* group and return specific data retrieved from parent data
|
|
1472
|
+
* @param {Object} currentContent
|
|
1473
|
+
* @returns {Object}
|
|
1474
|
+
*/
|
|
1475
|
+
function groupCurrentContentData(currentContent) {
|
|
1476
|
+
return {
|
|
1477
|
+
parentType: currentContent.parent_type,
|
|
1478
|
+
parentId: currentContent.parent_content_data[0].id,
|
|
1479
|
+
difficulty_string: currentContent.difficulty_string,
|
|
1480
|
+
brand: currentContent.brand,
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* fetch genres of parent content
|
|
1486
|
+
* @param {Object} contentData
|
|
1487
|
+
* @returns {Promise<Object|null>}
|
|
1488
|
+
*/
|
|
1489
|
+
async function fetchParentContentGenres(contentData) {
|
|
1490
|
+
const genreQuery = `*[_type == "${contentData.parentType}" && brand == "${contentData.brand}" && railcontent_id == ${contentData.parentId}][0]{"genre":genre[]->_id}`
|
|
1491
|
+
return fetchSanity(genreQuery, true)
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* combine data into Object
|
|
1496
|
+
* @param {Object} genres
|
|
1497
|
+
* @returns {string}
|
|
1498
|
+
*/
|
|
1499
|
+
function formatGenresToString(genres) {
|
|
1500
|
+
return JSON.stringify(genres['genre']).replace(/[\[\]]/g, '')
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* build filters for use in related_lessons query
|
|
1505
|
+
* @param {string} type
|
|
1506
|
+
* @param {string} brand
|
|
1507
|
+
* @param {number} id
|
|
1508
|
+
* @param {string} difficulty
|
|
1509
|
+
* @param {string|null} genres
|
|
1510
|
+
* @returns {Promise<string>}
|
|
1511
|
+
*/
|
|
1512
|
+
async function buildSubQueryForFetch(type, brand, id, difficulty, genres = null) {
|
|
1513
|
+
const genreString = genres ? `&& references([${genres}])` : ``
|
|
1514
|
+
return new FilterBuilder(
|
|
1515
|
+
`_type == "${type}" && brand == "${brand}" && railcontent_id != ${id} && difficulty_string == "${difficulty}" ${genreString}`
|
|
1516
|
+
).buildFilter()
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* format return Object for use by page
|
|
1521
|
+
* @param {Object} parentObject
|
|
1522
|
+
* @param {Object} relatedLessonObject
|
|
1523
|
+
* @returns {Object}
|
|
1524
|
+
*/
|
|
1525
|
+
function formatForResponse(parentObject, relatedLessonObject) {
|
|
1526
|
+
return { ...parentObject, related_lessons: relatedLessonObject }
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1348
1529
|
/**
|
|
1349
1530
|
* Fetch all packs.
|
|
1350
1531
|
* @param {string} brand - The brand for which to fetch packs.
|
|
@@ -1754,13 +1935,16 @@ function populateHierarchyLookups(currentLevel, data, parentId) {
|
|
|
1754
1935
|
* @returns {Promise<Object|null>} - A promise that resolves to an object containing the data
|
|
1755
1936
|
*/
|
|
1756
1937
|
export async function fetchCommentModContentData(ids) {
|
|
1938
|
+
if (!ids) {
|
|
1939
|
+
return []
|
|
1940
|
+
}
|
|
1757
1941
|
const idsString = ids.join(',')
|
|
1758
1942
|
const fields = `"id": railcontent_id, "type": _type, title, "url": web_url_path, "parent": *[^._id in child[]._ref]{"id": railcontent_id, title}`
|
|
1759
1943
|
const query = await buildQuery(
|
|
1760
1944
|
`railcontent_id in [${idsString}]`,
|
|
1761
1945
|
{ bypassPermissions: true },
|
|
1762
1946
|
fields,
|
|
1763
|
-
{ end:
|
|
1947
|
+
{ end: ids.length }
|
|
1764
1948
|
)
|
|
1765
1949
|
let data = await fetchSanity(query, true)
|
|
1766
1950
|
let mapped = {}
|
|
@@ -1866,9 +2050,8 @@ function needsAccessDecorator(results, userPermissions, isAdmin) {
|
|
|
1866
2050
|
result.lessons.forEach((lesson) => {
|
|
1867
2051
|
lesson['need_access'] = doesUserNeedAccessToContent(lesson, userPermissions, isAdmin) // Updated to check lesson access
|
|
1868
2052
|
})
|
|
1869
|
-
} else {
|
|
1870
|
-
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions, isAdmin)
|
|
1871
2053
|
}
|
|
2054
|
+
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions, isAdmin)
|
|
1872
2055
|
})
|
|
1873
2056
|
} else if (results.related_lessons && Array.isArray(results.related_lessons)) {
|
|
1874
2057
|
results.related_lessons.forEach((result) => {
|
|
@@ -2007,7 +2190,7 @@ function checkSanityConfig(config) {
|
|
|
2007
2190
|
function buildRawQuery(
|
|
2008
2191
|
filter = '',
|
|
2009
2192
|
fields = '...',
|
|
2010
|
-
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false}
|
|
2193
|
+
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
|
|
2011
2194
|
) {
|
|
2012
2195
|
const sortString = sortOrder ? `order(${sortOrder})` : ''
|
|
2013
2196
|
const countString = isSingle ? '[0...1]' : `[${start}...${end}]`
|
|
@@ -2021,10 +2204,10 @@ async function buildQuery(
|
|
|
2021
2204
|
baseFilter = '',
|
|
2022
2205
|
filterParams = { pullFutureContent: false },
|
|
2023
2206
|
fields = '...',
|
|
2024
|
-
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false}
|
|
2207
|
+
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
|
|
2025
2208
|
) {
|
|
2026
2209
|
const filter = await new FilterBuilder(baseFilter, filterParams).buildFilter()
|
|
2027
|
-
return buildRawQuery(filter, fields, { sortOrder, start, end, isSingle})
|
|
2210
|
+
return buildRawQuery(filter, fields, { sortOrder, start, end, isSingle })
|
|
2028
2211
|
}
|
|
2029
2212
|
|
|
2030
2213
|
function buildEntityAndTotalQuery(
|
|
@@ -2151,7 +2334,7 @@ function cleanUpGroq(query) {
|
|
|
2151
2334
|
<br class="clear">
|
|
2152
2335
|
|
|
2153
2336
|
<footer>
|
|
2154
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on
|
|
2337
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Jun 02 2025 15:37:28 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
2155
2338
|
</footer>
|
|
2156
2339
|
|
|
2157
2340
|
<script>prettyPrint();</script>
|
package/jsdoc.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musora-content-services",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A package for Musoras content services ",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/preset-env": "^7.25.3",
|
|
33
33
|
"@sanity/client": "^5.4.2",
|
|
34
|
+
"algoliasearch": "^5.25.0",
|
|
34
35
|
"babel-jest": "^29.7.0",
|
|
35
36
|
"docdash": "^2.0.2",
|
|
36
|
-
"groqd": "^0.15.12"
|
|
37
|
+
"groqd": "^0.15.12",
|
|
38
|
+
"instantsearch.js": "^4.78.3"
|
|
37
39
|
}
|
|
38
40
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
sendAlgoliaClickEvent
|
|
5
|
+
} from './services/algolia.js';
|
|
6
|
+
|
|
3
7
|
import {
|
|
4
8
|
globalConfig,
|
|
5
9
|
initializeService,
|
|
@@ -295,6 +299,7 @@ declare module 'musora-content-services' {
|
|
|
295
299
|
recordWatchSession,
|
|
296
300
|
reportPlaylist,
|
|
297
301
|
reset,
|
|
302
|
+
sendAlgoliaClickEvent,
|
|
298
303
|
setLastUpdatedTime,
|
|
299
304
|
setStudentViewForUser,
|
|
300
305
|
setUserMetadata,
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
sendAlgoliaClickEvent
|
|
5
|
+
} from './services/algolia.js';
|
|
6
|
+
|
|
3
7
|
import {
|
|
4
8
|
globalConfig,
|
|
5
9
|
initializeService,
|
|
@@ -294,6 +298,7 @@ export {
|
|
|
294
298
|
recordWatchSession,
|
|
295
299
|
reportPlaylist,
|
|
296
300
|
reset,
|
|
301
|
+
sendAlgoliaClickEvent,
|
|
297
302
|
setLastUpdatedTime,
|
|
298
303
|
setStudentViewForUser,
|
|
299
304
|
setUserMetadata,
|