musora-content-services 1.0.247 → 1.0.250
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 +6 -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 +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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.250](https://github.com/railroadmedia/musora-content-services/compare/v1.0.249...v1.0.250) (2024-12-19)
|
|
6
|
+
|
|
7
|
+
### [1.0.249](https://github.com/railroadmedia/musora-content-services/compare/v1.0.247...v1.0.249) (2024-12-19)
|
|
8
|
+
|
|
9
|
+
### [1.0.248](https://github.com/railroadmedia/musora-content-services/compare/v1.0.247...v1.0.248) (2024-12-19)
|
|
10
|
+
|
|
5
11
|
### [1.0.247](https://github.com/railroadmedia/musora-content-services/compare/v1.0.245...v1.0.247) (2024-12-18)
|
|
6
12
|
|
|
7
13
|
### [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,
|
|
@@ -1557,13 +1560,13 @@ export async function fetchArtistLessons(brand, name, contentType, {
|
|
|
1557
1560
|
|
|
1558
1561
|
// limits the results to supplied progressIds for started & completed filters
|
|
1559
1562
|
const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
|
|
1560
|
-
|
|
1563
|
+
const now = getSanityDate(new Date());
|
|
1561
1564
|
const query = `{
|
|
1562
1565
|
"entity":
|
|
1563
1566
|
*[_type == 'artist' && name == '${name}']
|
|
1564
1567
|
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1565
1568
|
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1566
|
-
'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1569
|
+
'lessons': *[${addType} brand == '${brand}' && references(^._id) && (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}')) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1567
1570
|
[${start}...${end}]}
|
|
1568
1571
|
|order(${sortOrder})
|
|
1569
1572
|
}`;
|
|
@@ -1607,13 +1610,13 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1607
1610
|
: "";
|
|
1608
1611
|
// limits the results to supplied progressIds for started & completed filters
|
|
1609
1612
|
const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
|
|
1610
|
-
|
|
1613
|
+
const now = getSanityDate(new Date());
|
|
1611
1614
|
const query = `{
|
|
1612
1615
|
"entity":
|
|
1613
1616
|
*[_type == 'genre' && name == '${name}']
|
|
1614
1617
|
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1615
1618
|
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1616
|
-
'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1619
|
+
'lessons': *[${addType} brand == '${brand}' && references(^._id) && (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}')) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1617
1620
|
[${start}...${end}]}
|
|
1618
1621
|
|order(${sortOrder})
|
|
1619
1622
|
}`;
|