musora-content-services 2.21.1 → 2.21.3
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 +15 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +6 -0
- package/src/index.d.ts +0 -0
- package/src/index.js +0 -0
- package/src/services/content-org/guided-courses.ts +0 -0
- package/src/services/content.js +0 -0
- package/src/services/contentAggregator.js +3 -17
- package/src/services/contentProgress.js +6 -6
- package/src/services/recommendations.js +0 -0
- package/src/services/sanity.js +9 -7
- package/src/services/userActivity.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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
|
+
### [2.21.3](https://github.com/railroadmedia/musora-content-services/compare/v2.21.1...v2.21.3) (2025-07-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* MU2-787 Leaving Soon and Returning should only be set in the future ([4bb48c9](https://github.com/railroadmedia/musora-content-services/commit/4bb48c93afa7b2167d94c306830a4db3e7dab810))
|
|
11
|
+
* **systest:** patch contentAggregator ([#342](https://github.com/railroadmedia/musora-content-services/issues/342)) ([4a1906e](https://github.com/railroadmedia/musora-content-services/commit/4a1906ed8e5cfc3cebf3e044d4eb35213d18ebe1))
|
|
12
|
+
|
|
13
|
+
### [2.21.2](https://github.com/railroadmedia/musora-content-services/compare/v2.21.1...v2.21.2) (2025-07-14)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **systest:** patch contentAggregator ([#342](https://github.com/railroadmedia/musora-content-services/issues/342)) ([4a1906e](https://github.com/railroadmedia/musora-content-services/commit/4a1906ed8e5cfc3cebf3e044d4eb35213d18ebe1))
|
|
19
|
+
|
|
5
20
|
### [2.21.1](https://github.com/railroadmedia/musora-content-services/compare/v2.21.0...v2.21.1) (2025-07-14)
|
|
6
21
|
|
|
7
22
|
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
package/src/index.d.ts
CHANGED
|
File without changes
|
package/src/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/services/content.js
CHANGED
|
File without changes
|
|
@@ -33,15 +33,14 @@ export async function addContextToContent(dataPromise, ...dataArgs)
|
|
|
33
33
|
if(!data) return false
|
|
34
34
|
|
|
35
35
|
let items = []
|
|
36
|
-
let dataMap = []
|
|
37
36
|
|
|
38
37
|
if (dataField && (data?.[dataField] || iterateDataFieldOnEachArrayElement)) {
|
|
39
38
|
if (iterateDataFieldOnEachArrayElement && Array.isArray(data)) {
|
|
40
39
|
for(const parent of data) {
|
|
41
|
-
|
|
40
|
+
items = [...items, ...parent[dataField]]
|
|
42
41
|
}
|
|
43
42
|
} else {
|
|
44
|
-
|
|
43
|
+
items = data[dataField]
|
|
45
44
|
}
|
|
46
45
|
} else if (Array.isArray(data)) {
|
|
47
46
|
items = data;
|
|
@@ -51,19 +50,6 @@ export async function addContextToContent(dataPromise, ...dataArgs)
|
|
|
51
50
|
|
|
52
51
|
const ids = items.map(item => item?.id).filter(Boolean)
|
|
53
52
|
|
|
54
|
-
//create data structure for common use by functions
|
|
55
|
-
if (addNextLesson) {
|
|
56
|
-
items.forEach((item) => {
|
|
57
|
-
if (item?.id) {
|
|
58
|
-
dataMap.push({
|
|
59
|
-
'children': item.children?.map(child => child.id) ?? [],
|
|
60
|
-
'type': item.type,
|
|
61
|
-
'id': item.id,
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
53
|
if(ids.length === 0) return false
|
|
68
54
|
|
|
69
55
|
const [progressPercentageData, progressStatusData, isLikedData, resumeTimeData, lastInteractedChildData, nextLessonData] = await Promise.all([
|
|
@@ -72,7 +58,7 @@ export async function addContextToContent(dataPromise, ...dataArgs)
|
|
|
72
58
|
addIsLiked ? isContentLikedByIds(ids) : Promise.resolve(null),
|
|
73
59
|
addResumeTimeSeconds ? getResumeTimeSecondsByIds(ids) : Promise.resolve(null),
|
|
74
60
|
addLastInteractedChild ? fetchLastInteractedChild(ids) : Promise.resolve(null),
|
|
75
|
-
(addNextLesson || addLastInteractedParent) ? getNextLesson(
|
|
61
|
+
(addNextLesson || addLastInteractedParent) ? getNextLesson(items) : Promise.resolve(null),
|
|
76
62
|
])
|
|
77
63
|
|
|
78
64
|
const addContext = async (item) => ({
|
|
@@ -44,12 +44,12 @@ export async function getResumeTimeSecondsByIds(contentIds) {
|
|
|
44
44
|
return getByIds(contentIds, DATA_KEY_RESUME_TIME, 0)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export async function getNextLesson(
|
|
47
|
+
export async function getNextLesson(data)
|
|
48
48
|
{
|
|
49
49
|
let nextLessonData = {}
|
|
50
50
|
|
|
51
|
-
for (const content of
|
|
52
|
-
|
|
51
|
+
for (const content of data) {
|
|
52
|
+
const children = content.children?.map(child => child.id) ?? []
|
|
53
53
|
//only calculate nextLesson if needed, based on content type
|
|
54
54
|
if (!getNextLessonLessonParentTypes.includes(content.type)) {
|
|
55
55
|
nextLessonData[content.id] = null
|
|
@@ -58,15 +58,15 @@ export async function getNextLesson(dataMap)
|
|
|
58
58
|
//return first child if parent-content is complete or no progress
|
|
59
59
|
const contentState = await getProgressState(content.id)
|
|
60
60
|
if (contentState !== STATE_STARTED) {
|
|
61
|
-
nextLessonData[content.id] =
|
|
61
|
+
nextLessonData[content.id] = children[0]
|
|
62
62
|
|
|
63
63
|
} else {
|
|
64
64
|
//if content in progress
|
|
65
65
|
|
|
66
|
-
const childrenStates = await getProgressStateByIds(
|
|
66
|
+
const childrenStates = await getProgressStateByIds(children)
|
|
67
67
|
|
|
68
68
|
//calculate last_engaged
|
|
69
|
-
const lastInteracted = await getLastInteractedOf(
|
|
69
|
+
const lastInteracted = await getLastInteractedOf(children)
|
|
70
70
|
const lastInteractedStatus = childrenStates[lastInteracted]
|
|
71
71
|
|
|
72
72
|
//different nextLesson behaviour for different content types
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -73,18 +73,19 @@ export async function fetchSongById(documentId) {
|
|
|
73
73
|
* @returns {Promise<Object|null>}
|
|
74
74
|
*/
|
|
75
75
|
export async function fetchLeaving(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
76
|
+
const today = new Date()
|
|
77
|
+
const isoDateOnly = today.toISOString().split('T')[0]
|
|
78
|
+
const filterString = `brand == '${brand}' && quarter_removed > '${isoDateOnly}'`
|
|
78
79
|
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
79
80
|
const sortOrder = {
|
|
80
|
-
sortOrder: 'published_on desc, id desc',
|
|
81
|
+
sortOrder: 'quarter_removed asc, published_on desc, id desc',
|
|
81
82
|
start: startEndOrder['start'],
|
|
82
83
|
end: startEndOrder['end'],
|
|
83
84
|
}
|
|
84
85
|
const query = await buildQuery(
|
|
85
86
|
filterString,
|
|
86
87
|
{ pullFutureContent: false, availableContentStatuses: ['published'] },
|
|
87
|
-
getFieldsForContentType(),
|
|
88
|
+
getFieldsForContentType('leaving'),
|
|
88
89
|
sortOrder
|
|
89
90
|
)
|
|
90
91
|
return fetchSanity(query, true)
|
|
@@ -99,11 +100,12 @@ export async function fetchLeaving(brand, { pageNumber = 1, contentPerPage = 20
|
|
|
99
100
|
* @returns {Promise<Object|null>}
|
|
100
101
|
*/
|
|
101
102
|
export async function fetchReturning(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
102
|
-
const
|
|
103
|
-
const
|
|
103
|
+
const today = new Date()
|
|
104
|
+
const isoDateOnly = today.toISOString().split('T')[0]
|
|
105
|
+
const filterString = `brand == '${brand}' && quarter_published >= '${isoDateOnly}'`
|
|
104
106
|
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
105
107
|
const sortOrder = {
|
|
106
|
-
sortOrder: 'published_on desc, id desc',
|
|
108
|
+
sortOrder: 'quarter_published asc, published_on desc, id desc',
|
|
107
109
|
start: startEndOrder['start'],
|
|
108
110
|
end: startEndOrder['end'],
|
|
109
111
|
}
|
|
File without changes
|