musora-content-services 1.0.92 → 1.0.94
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 +4 -0
- package/package.json +1 -1
- package/src/services/railcontent.js +22 -15
- package/src/services/sanity.js +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.94](https://github.com/railroadmedia/musora-content-services/compare/v1.0.93...v1.0.94) (2024-09-12)
|
|
6
|
+
|
|
7
|
+
### [1.0.93](https://github.com/railroadmedia/musora-content-services/compare/v1.0.92...v1.0.93) (2024-09-11)
|
|
8
|
+
|
|
5
9
|
### [1.0.92](https://github.com/railroadmedia/musora-content-services/compare/v1.0.91...v1.0.92) (2024-09-11)
|
|
6
10
|
|
|
7
11
|
### [1.0.91](https://github.com/railroadmedia/musora-content-services/compare/v1.0.90...v1.0.91) (2024-09-11)
|
package/package.json
CHANGED
|
@@ -126,7 +126,7 @@ export async function fetchSongsInProgress(brand) {
|
|
|
126
126
|
const response = await fetchAbsolute(url, { headers });
|
|
127
127
|
const result = await response.json();
|
|
128
128
|
if(result){
|
|
129
|
-
console.log('fetchSongsInProgress', result);
|
|
129
|
+
//console.log('fetchSongsInProgress', result);
|
|
130
130
|
return result;
|
|
131
131
|
} else {
|
|
132
132
|
console.log('result not json');
|
|
@@ -142,17 +142,20 @@ export async function fetchSongsInProgress(brand) {
|
|
|
142
142
|
*
|
|
143
143
|
* @param {string} type - The content type associated with the content.
|
|
144
144
|
* @param {string} brand - The brand associated with the content.
|
|
145
|
-
* @param {number} [limit=20] - The limit of results per page.
|
|
146
|
-
* @param {number} [page=1] - The page number for pagination.
|
|
145
|
+
* @param {number} [params.limit=20] - The limit of results per page.
|
|
146
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
147
147
|
* @returns {Promise<Object|null>} - Returns an object containing in-progress content if found, otherwise null.
|
|
148
148
|
* @example
|
|
149
149
|
* fetchContentInProgress('song', 'drumeo')
|
|
150
150
|
* .then(songs => console.log(songs))
|
|
151
151
|
* .catch(error => console.error(error));
|
|
152
152
|
*/
|
|
153
|
-
export async function fetchContentInProgress(type="all", brand,
|
|
153
|
+
export async function fetchContentInProgress(type="all", brand, {
|
|
154
|
+
page = 1,
|
|
155
|
+
limit = 10,
|
|
156
|
+
} = {}) {
|
|
154
157
|
let url;
|
|
155
|
-
if(type
|
|
158
|
+
if(type === "all") {
|
|
156
159
|
url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?brand=${brand}&limit=${limit}&page=${page}`;
|
|
157
160
|
} else {
|
|
158
161
|
url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=${type}&brand=${brand}&limit=${limit}&page=${page}`;
|
|
@@ -181,17 +184,20 @@ export async function fetchContentInProgress(type="all", brand, limit=20, page=1
|
|
|
181
184
|
*
|
|
182
185
|
* @param {string} type - The content type associated with the content.
|
|
183
186
|
* @param {string} brand - The brand associated with the content.
|
|
184
|
-
* @param {number} [limit=20] - The limit of results per page.
|
|
185
|
-
* @param {number} [page=1] - The page number for pagination.
|
|
187
|
+
* @param {number} [params.limit=20] - The limit of results per page.
|
|
188
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
186
189
|
* @returns {Promise<Object|null>} - Returns an object containing in-progress content if found, otherwise null.
|
|
187
190
|
* @example
|
|
188
191
|
* fetchCompletedContent('song', 'drumeo')
|
|
189
192
|
* .then(songs => console.log(songs))
|
|
190
193
|
* .catch(error => console.error(error));
|
|
191
194
|
*/
|
|
192
|
-
export async function fetchCompletedContent(type="all", brand,
|
|
195
|
+
export async function fetchCompletedContent(type="all", brand, {
|
|
196
|
+
page = 1,
|
|
197
|
+
limit = 10,
|
|
198
|
+
} = {}) {
|
|
193
199
|
let url;
|
|
194
|
-
if(type
|
|
200
|
+
if(type === "all") {
|
|
195
201
|
url = `/content/completed/${globalConfig.railcontentConfig.userId}?brand=${brand}&limit=${limit}&page=${page}`;
|
|
196
202
|
} else {
|
|
197
203
|
url = `/content/completed/${globalConfig.railcontentConfig.userId}?content_type=${type}&brand=${brand}&limit=${limit}&page=${page}`;
|
|
@@ -248,10 +254,11 @@ export async function fetchContentPageUserData(contentId) {
|
|
|
248
254
|
}
|
|
249
255
|
}
|
|
250
256
|
|
|
251
|
-
function fetchAbsolute(url, params) {
|
|
252
|
-
if
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
+
function fetchAbsolute(url, params) {
|
|
258
|
+
if(globalConfig.railcontentConfig.baseUrl) {
|
|
259
|
+
if (url.startsWith('/')) {
|
|
260
|
+
return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return fetch(url, params);
|
|
257
264
|
}
|
package/src/services/sanity.js
CHANGED
|
@@ -286,11 +286,14 @@ export async function fetchNewReleases(brand) {
|
|
|
286
286
|
* @returns {Promise<Object|null>} - A promise that resolves to an array of upcoming event objects or null if not found.
|
|
287
287
|
*
|
|
288
288
|
* @example
|
|
289
|
-
* fetchUpcomingEvents('drumeo'
|
|
289
|
+
* fetchUpcomingEvents('drumeo', {
|
|
290
|
+
* page: 2,
|
|
291
|
+
* limit: 20,
|
|
292
|
+
* })
|
|
290
293
|
* .then(events => console.log(events))
|
|
291
294
|
* .catch(error => console.error(error));
|
|
292
295
|
*/
|
|
293
|
-
export async function fetchUpcomingEvents(brand) {
|
|
296
|
+
export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 }) {
|
|
294
297
|
const baseLiveTypes = ["student-review", "student-reviews", "student-focus", "coach-stream", "live", "question-and-answer", "student-review", "boot-camps", "recording", "pack-bundle-lesson"];
|
|
295
298
|
const liveTypes = {
|
|
296
299
|
'drumeo': [...baseLiveTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "quick-tips", "student-collaborations", "live-streams", "podcasts", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums"],
|
|
@@ -301,6 +304,8 @@ export async function fetchUpcomingEvents(brand) {
|
|
|
301
304
|
};
|
|
302
305
|
const typesString = arrayJoinWithQuotes(liveTypes[brand] ?? liveTypes['default']);
|
|
303
306
|
const now = getSanityDate(new Date());
|
|
307
|
+
const start = (page - 1) * limit;
|
|
308
|
+
const end = start + limit;
|
|
304
309
|
const query = `*[_type in [${typesString}] && brand == '${brand}' && published_on > '${now}' && status == 'scheduled']{
|
|
305
310
|
"id": railcontent_id,
|
|
306
311
|
title,
|
|
@@ -313,7 +318,7 @@ export async function fetchUpcomingEvents(brand) {
|
|
|
313
318
|
published_on,
|
|
314
319
|
"type": _type,
|
|
315
320
|
web_url_path,
|
|
316
|
-
|
|
321
|
+
} | order(published_on asc)[${start}...${end}]`;
|
|
317
322
|
return fetchSanity(query, true);
|
|
318
323
|
}
|
|
319
324
|
|