musora-content-services 1.0.239 → 1.0.241

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.241](https://github.com/railroadmedia/musora-content-services/compare/v1.0.240...v1.0.241) (2024-12-16)
6
+
7
+ ### [1.0.240](https://github.com/railroadmedia/musora-content-services/compare/v1.0.239...v1.0.240) (2024-12-16)
8
+
5
9
  ### [1.0.239](https://github.com/railroadmedia/musora-content-services/compare/v1.0.238...v1.0.239) (2024-12-16)
6
10
 
7
11
  ### [1.0.238](https://github.com/railroadmedia/musora-content-services/compare/v1.0.237...v1.0.238) (2024-12-16)
package/link_mcs.sh CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.239",
3
+ "version": "1.0.241",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -162,12 +162,19 @@ const commonMetadata ={
162
162
  allowableFilters: ['difficulty', 'genre', 'essential', 'theory'],
163
163
  sortBy: '-published_on',
164
164
  },
165
+ 'recommendation': {
166
+ tabs: [
167
+ { name: 'All', is_group_by: true, value: ['group_by,Recommended']},
168
+ { name: 'Songs', value: ['filter,song'] },
169
+ { name: 'Lessons', value: ['filter,lesson']},
170
+ ],
171
+ },
165
172
  'workout': {
166
173
  name: "Workouts",
167
174
  shortname: 'Workouts',
168
175
  allowableFilters: ['difficulty', 'genre', 'topic'],
169
176
  tabs: [
170
- {
177
+ {
171
178
  name: 'All',
172
179
  short_name: 'ALL',
173
180
  value: '',
@@ -449,7 +449,20 @@ export async function fetchByRailContentIds(ids, contentType = undefined) {
449
449
  const query = `*[railcontent_id in [${idsString}]]{
450
450
  ${getFieldsForContentType(contentType)}
451
451
  }`
452
- return fetchSanity(query, true);
452
+ const results = await fetchSanity(query, true);
453
+
454
+ const sortFuction = function compare(a,b){
455
+ const indexA = ids.indexOf(a['id']);
456
+ const indexB = ids.indexOf(b['id'])
457
+ if(indexA === indexB) return 0;
458
+ if(indexA > indexB) return 1;
459
+ return -1;
460
+ }
461
+
462
+ // Sort results to match the order of the input IDs
463
+ const sortedResults = results.sort(sortFuction);
464
+
465
+ return sortedResults;
453
466
  }
454
467
 
455
468
  /**
@@ -123,10 +123,19 @@ describe('Sanity Queries', function () {
123
123
  const id2 = 402204;
124
124
  const response = await fetchByRailContentIds([id, id2]);
125
125
  const returnedIds = response.map((x) => x.id);
126
- expect(returnedIds).toContain(id);
127
- expect(returnedIds).toContain(id2);
126
+ expect(returnedIds[0]).toBe(id);
127
+ expect(returnedIds[1]).toBe(id2);
128
128
  expect(returnedIds.length).toBe(2);
129
+ });
129
130
 
131
+ test('fetchByRailContentIds_Order', async () => {
132
+ const id = 380094;
133
+ const id2 = 402204;
134
+ const response = await fetchByRailContentIds([id2, id]);
135
+ const returnedIds = response.map((x) => x.id);
136
+ expect(returnedIds[0]).toBe(id2);
137
+ expect(returnedIds[1]).toBe(id);
138
+ expect(returnedIds.length).toBe(2);
130
139
  });
131
140
 
132
141
  test('fetchUpcomingEvents', async () => {