musora-content-services 1.0.198 → 1.0.199
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/docs/config.js.html +0 -0
- package/docs/index.html +0 -0
- package/docs/module-Config.html +0 -0
- package/docs/module-Railcontent-Services.html +0 -0
- package/docs/module-Sanity-Services.html +0 -0
- package/docs/railcontent.js.html +0 -0
- package/docs/sanity.js.html +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +0 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +0 -0
- package/src/index.js +0 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/sanity.js +13 -9
- package/test/contentProgress.test.js +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/live/railcontentLive.test.js +0 -0
- package/test/sanityQueryService.test.js +1 -1
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.199](https://github.com/railroadmedia/musora-content-services/compare/v1.0.198...v1.0.199) (2024-11-29)
|
|
6
|
+
|
|
5
7
|
### [1.0.198](https://github.com/railroadmedia/musora-content-services/compare/v1.0.185...v1.0.198) (2024-11-29)
|
|
6
8
|
|
|
7
9
|
### [1.0.197](https://github.com/railroadmedia/musora-content-services/compare/v1.0.196...v1.0.197) (2024-11-29)
|
package/docs/config.js.html
CHANGED
|
File without changes
|
package/docs/index.html
CHANGED
|
File without changes
|
package/docs/module-Config.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/railcontent.js.html
CHANGED
|
File without changes
|
package/docs/sanity.js.html
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentMetaData.js
CHANGED
|
File without changes
|
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
File without changes
|
package/src/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -284,7 +284,7 @@ export async function fetchNewReleases(brand, {page = 1, limit = 20, sort = "-pu
|
|
|
284
284
|
const typesString = arrayToStringRepresentation(newTypes);
|
|
285
285
|
const start = (page - 1) * limit;
|
|
286
286
|
const end = start + limit;
|
|
287
|
-
const sortOrder = getSortOrder(sort);
|
|
287
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
288
288
|
const filter = `_type in ${typesString} && brand == '${brand}'`;
|
|
289
289
|
const fields = `
|
|
290
290
|
"id": railcontent_id,
|
|
@@ -532,7 +532,7 @@ export async function fetchAll(brand, type, {
|
|
|
532
532
|
const progressFilter = await getProgressFilter(progress, progressIds);
|
|
533
533
|
|
|
534
534
|
// Determine the sort order
|
|
535
|
-
const sortOrder = getSortOrder(sort, groupBy);
|
|
535
|
+
const sortOrder = getSortOrder(sort, brand, groupBy);
|
|
536
536
|
|
|
537
537
|
let fields = useDefaultFields ? customFields.concat(DEFAULT_FIELDS, additionalFields) : customFields;
|
|
538
538
|
let fieldsString = fields.join(',');
|
|
@@ -742,7 +742,7 @@ async function getProgressFilter(progress, progressIds) {
|
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
-
export function getSortOrder(sort = '-published_on', groupBy) {
|
|
745
|
+
export function getSortOrder(sort = '-published_on', brand, groupBy) {
|
|
746
746
|
// Determine the sort order
|
|
747
747
|
let sortOrder = '';
|
|
748
748
|
const isDesc = sort.startsWith('-');
|
|
@@ -755,7 +755,11 @@ export function getSortOrder(sort = '-published_on', groupBy) {
|
|
|
755
755
|
sortOrder = sort;
|
|
756
756
|
break;
|
|
757
757
|
case "popularity":
|
|
758
|
-
|
|
758
|
+
if (groupBy == "artist" || groupBy == "") {
|
|
759
|
+
sortOrder = isDesc ? `coalesce(popularity.${brand}, -1)` : "popularity";
|
|
760
|
+
} else {
|
|
761
|
+
sortOrder = isDesc ? "coalesce(popularity, -1)" : "popularity";
|
|
762
|
+
}
|
|
759
763
|
break;
|
|
760
764
|
case "published_on":
|
|
761
765
|
default:
|
|
@@ -1201,7 +1205,7 @@ export async function fetchRelatedMethodLessons(railContentId, brand) {
|
|
|
1201
1205
|
* @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
|
|
1202
1206
|
*/
|
|
1203
1207
|
export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "", page = 1, limit = 10) {
|
|
1204
|
-
const sortOrder = getSortOrder(sort);
|
|
1208
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
1205
1209
|
const filter = `_type == 'pack' && brand == '${brand}' && title match "${searchTerm}*"`
|
|
1206
1210
|
const filterParams = {};
|
|
1207
1211
|
const fields = getFieldsForContentType('pack');
|
|
@@ -1359,7 +1363,7 @@ export async function fetchCoachLessons(brand, id, {
|
|
|
1359
1363
|
: "";
|
|
1360
1364
|
const filter = `brand == '${brand}' ${searchFilter} ${includedFieldsFilter} && references(*[_type=='instructor' && railcontent_id == ${id}]._id)`;
|
|
1361
1365
|
|
|
1362
|
-
sortOrder = getSortOrder(sortOrder);
|
|
1366
|
+
sortOrder = getSortOrder(sortOrder, brand);
|
|
1363
1367
|
const query = buildEntityAndTotalQuery(
|
|
1364
1368
|
filter,
|
|
1365
1369
|
fieldsString,
|
|
@@ -1440,7 +1444,7 @@ export async function fetchByReference(brand, {
|
|
|
1440
1444
|
filterWithRestrictions,
|
|
1441
1445
|
fieldsString,
|
|
1442
1446
|
{
|
|
1443
|
-
sortOrder: getSortOrder(sortOrder),
|
|
1447
|
+
sortOrder: getSortOrder(sortOrder, brand),
|
|
1444
1448
|
start: start,
|
|
1445
1449
|
end: end,
|
|
1446
1450
|
},
|
|
@@ -1480,7 +1484,7 @@ export async function fetchArtistLessons(brand, name, contentType, {
|
|
|
1480
1484
|
const start = (page - 1) * limit;
|
|
1481
1485
|
const end = start + limit;
|
|
1482
1486
|
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"` : ''
|
|
1483
|
-
const sortOrder = getSortOrder(sort);
|
|
1487
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
1484
1488
|
const addType = contentType && Array.isArray(contentType) ? `_type in ['${contentType.join("', '")}'] &&` : contentType ? `_type == '${contentType}' && ` : ''
|
|
1485
1489
|
const includedFieldsFilter = includedFields.length > 0
|
|
1486
1490
|
? filtersToGroq(includedFields)
|
|
@@ -1531,7 +1535,7 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1531
1535
|
const start = (page - 1) * limit;
|
|
1532
1536
|
const end = start + limit;
|
|
1533
1537
|
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"` : ''
|
|
1534
|
-
const sortOrder = getSortOrder(sort);
|
|
1538
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
1535
1539
|
const addType = contentType ? `_type == '${contentType}' && ` : ''
|
|
1536
1540
|
const includedFieldsFilter = includedFields.length > 0
|
|
1537
1541
|
? filtersToGroq(includedFields)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -382,7 +382,7 @@ describe('Sanity Queries', function () {
|
|
|
382
382
|
expect(sort).toBe('title asc');
|
|
383
383
|
sort = getSortOrder('-slug')
|
|
384
384
|
expect(sort).toBe('title desc');
|
|
385
|
-
sort = getSortOrder('-slug', true)
|
|
385
|
+
sort = getSortOrder('-slug', 'drumeo', true);
|
|
386
386
|
expect(sort).toBe('name desc');
|
|
387
387
|
sort = getSortOrder('published-on')
|
|
388
388
|
expect(sort).toBe('published_on asc');
|