musora-content-services 1.0.93 → 1.0.95

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 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.95](https://github.com/railroadmedia/musora-content-services/compare/v1.0.94...v1.0.95) (2024-09-12)
6
+
7
+ ### [1.0.94](https://github.com/railroadmedia/musora-content-services/compare/v1.0.93...v1.0.94) (2024-09-12)
8
+
5
9
  ### [1.0.93](https://github.com/railroadmedia/musora-content-services/compare/v1.0.92...v1.0.93) (2024-09-11)
6
10
 
7
11
  ### [1.0.92](https://github.com/railroadmedia/musora-content-services/compare/v1.0.91...v1.0.92) (2024-09-11)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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 !== "all") {
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 !== "all") {
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 (url.startsWith('/')) {
259
- return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
260
- } else {
261
- return fetch(url, params);
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
  }
@@ -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
- } | order(published_on asc)[0...5]`;
321
+ } | order(published_on asc)[${start}...${end}]`;
317
322
  return fetchSanity(query, true);
318
323
  }
319
324
 
@@ -437,6 +442,7 @@ export async function fetchAll(brand, type, {
437
442
  'type': _type,
438
443
  name,
439
444
  'head_shot_picture_url': thumbnail_url.asset->url,
445
+ web_url_path,
440
446
  'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]._id),
441
447
  'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{
442
448
  ${fieldsString},
@@ -456,6 +462,7 @@ export async function fetchAll(brand, type, {
456
462
  'type': _type,
457
463
  name,
458
464
  'head_shot_picture_url': thumbnail_url.asset->url,
465
+ web_url_path,
459
466
  'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]._id),
460
467
  'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{
461
468
  ${fieldsString},