musora-content-services 1.0.132 → 1.0.134

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.134](https://github.com/railroadmedia/musora-content-services/compare/v1.0.133...v1.0.134) (2024-10-11)
6
+
7
+ ### [1.0.133](https://github.com/railroadmedia/musora-content-services/compare/v1.0.132...v1.0.133) (2024-10-10)
8
+
5
9
  ### [1.0.132](https://github.com/railroadmedia/musora-content-services/compare/v1.0.131...v1.0.132) (2024-10-10)
6
10
 
7
11
  ### [1.0.131](https://github.com/railroadmedia/musora-content-services/compare/v1.0.130...v1.0.131) (2024-10-10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.132",
3
+ "version": "1.0.134",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -176,13 +176,19 @@ const commonMetadata ={
176
176
  name: '5 Minutes',
177
177
  short_name: '5 MINS',
178
178
  is_required_field: true,
179
- value: 'length_in_seconds < 450',
179
+ value: 'length_in_seconds,-450',
180
180
  },
181
181
  {
182
182
  name: '10 Minutes',
183
183
  short_name: '10 MINS',
184
184
  is_required_field: true,
185
- value: 'length_in_seconds > 450 && length_in_seconds < 750',
185
+ value: 'length_in_seconds,450-750',
186
+ },
187
+ {
188
+ name: '15+ Minutes',
189
+ short_name: '15+ MINS',
190
+ is_required_field: true,
191
+ value: 'length_in_seconds,750+',
186
192
  },
187
193
  {
188
194
  name: 'Instructors',
@@ -251,25 +257,25 @@ const contentMetadata = {
251
257
  name: 'Drags',
252
258
  short_name: 'DRAGS',
253
259
  is_required_field: true,
254
- value: 'topic[]->name match "drags"',
260
+ value: 'topic,drags',
255
261
  },
256
262
  {
257
263
  name: 'Flams',
258
264
  short_name: 'FLAMS',
259
265
  is_required_field: true,
260
- value: 'topic[]->name match "flams"',
266
+ value: 'topic,flams',
261
267
  },
262
268
  {
263
269
  name: 'Paradiddles',
264
270
  short_name: 'PARADIDDLES',
265
271
  is_required_field: true,
266
- value: 'topic[]->name match "paradiddles"',
272
+ value: 'topic,paradiddles',
267
273
  },
268
274
  {
269
275
  name: 'Rolls',
270
276
  short_name: 'ROLLS',
271
277
  is_required_field: true,
272
- value: 'topic[]->name match "rolls"',
278
+ value: 'topic,rolls',
273
279
  },
274
280
  ],
275
281
  sortBy: 'sort',
@@ -1064,6 +1070,33 @@ const contentMetadata = {
1064
1070
  hlsManifestUrl: "https://player.vimeo.com/external/578243377.m3u8?s=3def726f48a4a300420f793090e4913a48c8d1f9&oauth2_token_id=1284792283"
1065
1071
  }
1066
1072
  },
1073
+ 'workout': {
1074
+ tabs: [
1075
+ {
1076
+ name: 'All',
1077
+ short_name: 'ALL',
1078
+ value: '',
1079
+ },
1080
+ {
1081
+ name: '5 Minutes',
1082
+ short_name: '5 MINS',
1083
+ is_required_field: true,
1084
+ value: 'length_in_seconds,-450',
1085
+ },
1086
+ {
1087
+ name: '10 Minutes',
1088
+ short_name: '10 MINS',
1089
+ is_required_field: true,
1090
+ value: 'length_in_seconds,450-750',
1091
+ },
1092
+ {
1093
+ name: 'Instructors',
1094
+ short_name: 'INSTRUCTORS',
1095
+ is_group_by: true,
1096
+ value: 'instructor',
1097
+ },
1098
+ ],
1099
+ },
1067
1100
  }
1068
1101
  };
1069
1102
 
@@ -386,6 +386,16 @@ function filtersToGroq(filters, selectedFilters = []) {
386
386
  return `difficulty_string == "${value}"`;
387
387
  } else if (key === 'type' && !selectedFilters.includes(key)) {
388
388
  return `_type == "${value}"`;
389
+ } else if (key === 'length_in_seconds') {
390
+ if (value.includes('-')) {
391
+ const [min, max] = value.split('-').map(Number);
392
+ return `(${key} > ${min} && ${key} < ${max})`;
393
+ } else if (value.includes('+')) {
394
+ const min = parseInt(value, 10);
395
+ return `(${key} > ${min})`;
396
+ } else {
397
+ return `${key} == ${value}`;
398
+ }
389
399
  } else if (!selectedFilters.includes(key)) {
390
400
  return ` ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`;
391
401
  }
@@ -1214,10 +1214,17 @@ export async function fetchByReference(brand, {
1214
1214
  * @param {string} brand - The brand for which to fetch lessons.
1215
1215
  * @param {string} name - The name of the artist
1216
1216
  * @param {string} contentType - The type of the lessons we need to get from the artist. If not defined, groq will get lessons from all content types
1217
+ * @param {Object} params - Parameters for sorting, searching, pagination and filtering.
1218
+ * @param {string} [params.sort="-published_on"] - The field to sort the lessons by.
1219
+ * @param {string} [params.searchTerm=""] - The search term to filter the lessons.
1220
+ * @param {number} [params.page=1] - The page number for pagination.
1221
+ * @param {number} [params.limit=10] - The number of items per page.
1222
+ * @param {Array<string>} [params.includedFields=[]] - Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
1223
+ * @param {Array<number>} [params.progressIds] - The ids of the lessons that are in progress or completed
1217
1224
  * @returns {Promise<Object|null>} - The lessons for the artist and some details about the artist (name and thumbnail).
1218
1225
  *
1219
1226
  * @example
1220
- * fetchArtistLessons('10 Years', 'song')
1227
+ * fetchArtistLessons('drumeo', '10 Years', 'song', {'-published_on', '', 1, 10, ["difficulty,Intermediate"], [232168, 232824, 303375, 232194, 393125]})
1221
1228
  * .then(lessons => console.log(lessons))
1222
1229
  * .catch(error => console.error(error));
1223
1230
  */
@@ -1227,7 +1234,9 @@ export async function fetchArtistLessons(brand, name, contentType, {
1227
1234
  page = 1,
1228
1235
  limit = 10,
1229
1236
  includedFields = [],
1237
+ progressIds = undefined,
1230
1238
  } = {}) {
1239
+
1231
1240
  const fieldsString = DEFAULT_FIELDS.join(',');
1232
1241
  const start = (page - 1) * limit;
1233
1242
  const end = start + limit;
@@ -1238,12 +1247,15 @@ export async function fetchArtistLessons(brand, name, contentType, {
1238
1247
  ? filtersToGroq(includedFields)
1239
1248
  : "";
1240
1249
 
1250
+ // limits the results to supplied progressIds for started & completed filters
1251
+ const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
1252
+
1241
1253
  const query = `{
1242
1254
  "entity":
1243
1255
  *[_type == 'artist' && name == '${name}']
1244
1256
  {'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
1245
1257
  'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
1246
- 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter}]{${fieldsString}}
1258
+ 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
1247
1259
  [${start}...${end}]}
1248
1260
  |order(${sortOrder})
1249
1261
  }`;
@@ -1254,11 +1266,17 @@ export async function fetchArtistLessons(brand, name, contentType, {
1254
1266
  * Fetch the genre's lessons.
1255
1267
  * @param {string} brand - The brand for which to fetch lessons.
1256
1268
  * @param {string} name - The name of the genre
1257
- * @param {string} contentType - The type of the lessons we need to get from the genre. If not defined, groq will get lessons from all content types
1258
- * @returns {Promise<Object|null>} - The lessons for the genre and some details about the genre (name and thumbnail).
1269
+ * @param {Object} params - Parameters for sorting, searching, pagination and filtering.
1270
+ * @param {string} [params.sort="-published_on"] - The field to sort the lessons by.
1271
+ * @param {string} [params.searchTerm=""] - The search term to filter the lessons.
1272
+ * @param {number} [params.page=1] - The page number for pagination.
1273
+ * @param {number} [params.limit=10] - The number of items per page.
1274
+ * @param {Array<string>} [params.includedFields=[]] - Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
1275
+ * @param {Array<number>} [params.progressIds] - The ids of the lessons that are in progress or completed
1276
+ * @returns {Promise<Object|null>} - The lessons for the artist and some details about the artist (name and thumbnail).
1259
1277
  *
1260
1278
  * @example
1261
- * fetchGenreLessons('Blues', 'song')
1279
+ * fetchGenreLessons('drumeo', 'Blues', 'song', {'-published_on', '', 1, 10, ["difficulty,Intermediate"], [232168, 232824, 303375, 232194, 393125]})
1262
1280
  * .then(lessons => console.log(lessons))
1263
1281
  * .catch(error => console.error(error));
1264
1282
  */
@@ -1268,6 +1286,7 @@ export async function fetchGenreLessons(brand, name, contentType, {
1268
1286
  page = 1,
1269
1287
  limit = 10,
1270
1288
  includedFields = [],
1289
+ progressIds = undefined,
1271
1290
  } = {}) {
1272
1291
  const fieldsString = DEFAULT_FIELDS.join(',');
1273
1292
  const start = (page - 1) * limit;
@@ -1278,13 +1297,15 @@ export async function fetchGenreLessons(brand, name, contentType, {
1278
1297
  const includedFieldsFilter = includedFields.length > 0
1279
1298
  ? filtersToGroq(includedFields)
1280
1299
  : "";
1300
+ // limits the results to supplied progressIds for started & completed filters
1301
+ const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
1281
1302
 
1282
1303
  const query = `{
1283
1304
  "entity":
1284
1305
  *[_type == 'genre' && name == '${name}']
1285
1306
  {'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
1286
1307
  'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
1287
- 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter}]{${fieldsString}}
1308
+ 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
1288
1309
  [${start}...${end}]}
1289
1310
  |order(${sortOrder})
1290
1311
  }`;
File without changes