musora-content-services 1.0.247 → 1.0.251
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 +8 -0
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/services/contentProgress.js +2 -2
- package/src/services/dataContext.js +2 -2
- package/src/services/sanity.js +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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.251](https://github.com/railroadmedia/musora-content-services/compare/v1.0.250...v1.0.251) (2024-12-19)
|
|
6
|
+
|
|
7
|
+
### [1.0.250](https://github.com/railroadmedia/musora-content-services/compare/v1.0.249...v1.0.250) (2024-12-19)
|
|
8
|
+
|
|
9
|
+
### [1.0.249](https://github.com/railroadmedia/musora-content-services/compare/v1.0.247...v1.0.249) (2024-12-19)
|
|
10
|
+
|
|
11
|
+
### [1.0.248](https://github.com/railroadmedia/musora-content-services/compare/v1.0.247...v1.0.248) (2024-12-19)
|
|
12
|
+
|
|
5
13
|
### [1.0.247](https://github.com/railroadmedia/musora-content-services/compare/v1.0.245...v1.0.247) (2024-12-18)
|
|
6
14
|
|
|
7
15
|
### [1.0.246](https://github.com/railroadmedia/musora-content-services/compare/v1.0.244...v1.0.246) (2024-12-18)
|
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -265,10 +265,10 @@ function uuidv4() {
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
function bubbleProgress(hierarchy, contentId, localContext) {
|
|
268
|
-
let parentId = hierarchy
|
|
268
|
+
let parentId = hierarchy?.parents?.[contentId];
|
|
269
269
|
if (!parentId) return;
|
|
270
270
|
let data = localContext.data[parentId] ?? {};
|
|
271
|
-
let childProgress = hierarchy
|
|
271
|
+
let childProgress = hierarchy?.children?.[parentId]?.map(function (childId) {
|
|
272
272
|
return localContext.data[childId]?.[DATA_KEY_PROGRESS] ?? 0;
|
|
273
273
|
});
|
|
274
274
|
let progress = Math.round(childProgress.reduce((a, b) => a + b, 0) / childProgress.length);
|
|
@@ -38,7 +38,7 @@ export class DataContext {
|
|
|
38
38
|
if ((!this.context) || shouldVerify) {
|
|
39
39
|
let version = this.version();
|
|
40
40
|
let data = await this.fetchData(version);
|
|
41
|
-
if (data
|
|
41
|
+
if (data?.version !== "No Change") {
|
|
42
42
|
this.context = data;
|
|
43
43
|
cache.setItem(this.localStorageKey, JSON.stringify(data));
|
|
44
44
|
}
|
|
@@ -89,7 +89,7 @@ export class DataContext {
|
|
|
89
89
|
await this.ensureLocalContextLoaded();
|
|
90
90
|
if (this.context) {
|
|
91
91
|
await localUpdateFunction(this.context);
|
|
92
|
-
this.context.version++;
|
|
92
|
+
if (this.context) this.context.version++;
|
|
93
93
|
let data = JSON.stringify(this.context);
|
|
94
94
|
cache.setItem(this.localStorageKey, data);
|
|
95
95
|
cache.setItem(this.localStorageLastUpdatedKey, new Date().getTime().toString());
|
package/src/services/sanity.js
CHANGED
|
@@ -115,10 +115,12 @@ export async function fetchPlayAlongsCount(brand) {
|
|
|
115
115
|
* .catch(error => console.error(error));
|
|
116
116
|
*/
|
|
117
117
|
export async function fetchRelatedSongs(brand, songId) {
|
|
118
|
+
const now = getSanityDate(new Date());
|
|
118
119
|
const query = `
|
|
119
120
|
*[_type == "song" && railcontent_id == ${songId}]{
|
|
120
121
|
"entity": array::unique([
|
|
121
|
-
...(*[_type == "song" && brand == "${brand}" && railcontent_id != ${songId} && references(^.artist->_id)
|
|
122
|
+
...(*[_type == "song" && brand == "${brand}" && railcontent_id != ${songId} && references(^.artist->_id)
|
|
123
|
+
&& (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}'))]{
|
|
122
124
|
"type": _type,
|
|
123
125
|
"id": railcontent_id,
|
|
124
126
|
"url": web_url_path,
|
|
@@ -144,7 +146,8 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
144
146
|
}
|
|
145
147
|
],
|
|
146
148
|
}[0...10]),
|
|
147
|
-
...(*[_type == "song" && brand == "${brand}" && railcontent_id != ${songId} && references(^.genre[]->_id)
|
|
149
|
+
...(*[_type == "song" && brand == "${brand}" && railcontent_id != ${songId} && references(^.genre[]->_id)
|
|
150
|
+
&& (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}'))]{
|
|
148
151
|
"type": _type,
|
|
149
152
|
"id": railcontent_id,
|
|
150
153
|
"url": web_url_path,
|
|
@@ -539,6 +542,8 @@ export async function fetchAll(brand, type, {
|
|
|
539
542
|
if (type === 'archives') {
|
|
540
543
|
typeFilter = `&& status == "archived"`;
|
|
541
544
|
bypassStatusAndPublishedValidation = true;
|
|
545
|
+
} else if(type === 'pack'){
|
|
546
|
+
typeFilter = `&& (_type == 'pack' || _type == 'semester-pack')`;
|
|
542
547
|
} else {
|
|
543
548
|
typeFilter = type ? `&& _type == '${type}'` : "";
|
|
544
549
|
}
|
|
@@ -1557,13 +1562,13 @@ export async function fetchArtistLessons(brand, name, contentType, {
|
|
|
1557
1562
|
|
|
1558
1563
|
// limits the results to supplied progressIds for started & completed filters
|
|
1559
1564
|
const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
|
|
1560
|
-
|
|
1565
|
+
const now = getSanityDate(new Date());
|
|
1561
1566
|
const query = `{
|
|
1562
1567
|
"entity":
|
|
1563
1568
|
*[_type == 'artist' && name == '${name}']
|
|
1564
1569
|
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1565
1570
|
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1566
|
-
'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1571
|
+
'lessons': *[${addType} brand == '${brand}' && references(^._id) && (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}')) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1567
1572
|
[${start}...${end}]}
|
|
1568
1573
|
|order(${sortOrder})
|
|
1569
1574
|
}`;
|
|
@@ -1607,13 +1612,13 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1607
1612
|
: "";
|
|
1608
1613
|
// limits the results to supplied progressIds for started & completed filters
|
|
1609
1614
|
const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
|
|
1610
|
-
|
|
1615
|
+
const now = getSanityDate(new Date());
|
|
1611
1616
|
const query = `{
|
|
1612
1617
|
"entity":
|
|
1613
1618
|
*[_type == 'genre' && name == '${name}']
|
|
1614
1619
|
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1615
1620
|
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1616
|
-
'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1621
|
+
'lessons': *[${addType} brand == '${brand}' && references(^._id) && (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}')) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1617
1622
|
[${start}...${end}]}
|
|
1618
1623
|
|order(${sortOrder})
|
|
1619
1624
|
}`;
|