musora-content-services 1.0.93 → 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 +2 -0
- package/package.json +1 -1
- package/src/services/railcontent.js +10 -9
- package/src/services/sanity.js +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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
|
+
|
|
5
7
|
### [1.0.93](https://github.com/railroadmedia/musora-content-services/compare/v1.0.92...v1.0.93) (2024-09-11)
|
|
6
8
|
|
|
7
9
|
### [1.0.92](https://github.com/railroadmedia/musora-content-services/compare/v1.0.91...v1.0.92) (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');
|
|
@@ -155,7 +155,7 @@ export async function fetchContentInProgress(type="all", brand, {
|
|
|
155
155
|
limit = 10,
|
|
156
156
|
} = {}) {
|
|
157
157
|
let url;
|
|
158
|
-
if(type
|
|
158
|
+
if(type === "all") {
|
|
159
159
|
url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?brand=${brand}&limit=${limit}&page=${page}`;
|
|
160
160
|
} else {
|
|
161
161
|
url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=${type}&brand=${brand}&limit=${limit}&page=${page}`;
|
|
@@ -197,7 +197,7 @@ export async function fetchCompletedContent(type="all", brand, {
|
|
|
197
197
|
limit = 10,
|
|
198
198
|
} = {}) {
|
|
199
199
|
let url;
|
|
200
|
-
if(type
|
|
200
|
+
if(type === "all") {
|
|
201
201
|
url = `/content/completed/${globalConfig.railcontentConfig.userId}?brand=${brand}&limit=${limit}&page=${page}`;
|
|
202
202
|
} else {
|
|
203
203
|
url = `/content/completed/${globalConfig.railcontentConfig.userId}?content_type=${type}&brand=${brand}&limit=${limit}&page=${page}`;
|
|
@@ -254,10 +254,11 @@ export async function fetchContentPageUserData(contentId) {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
function fetchAbsolute(url, params) {
|
|
258
|
-
if
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
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);
|
|
263
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
|
|