musora-content-services 2.135.2 → 2.135.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 +2 -0
- package/package.json +1 -1
- package/src/services/awards/internal/award-manager.js +1 -1
- package/src/services/contentAggregator.js +3 -3
- package/src/services/contentProgress.js +7 -7
- package/src/services/progress-row/rows/content-card.js +1 -1
- package/src/services/userActivity.js +6 -5
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
|
+
### [2.135.3](https://github.com/railroadmedia/musora-content-services/compare/v2.135.2...v2.135.3) (2026-02-19)
|
|
6
|
+
|
|
5
7
|
### [2.135.2](https://github.com/railroadmedia/musora-content-services/compare/v2.135.1...v2.135.2) (2026-02-19)
|
|
6
8
|
|
|
7
9
|
### [2.135.1](https://github.com/railroadmedia/musora-content-services/compare/v2.135.0...v2.135.1) (2026-02-19)
|
package/package.json
CHANGED
|
@@ -110,7 +110,7 @@ export async function addContextToContent(dataPromise, ...dataArgs) {
|
|
|
110
110
|
...(addProgressTimestamp ? { progressTimestamp: progressData?.[item.id]?.last_update } : {}),
|
|
111
111
|
...(addIsLiked ? { isLiked: isLikedData?.[item.id] } : {}),
|
|
112
112
|
...(addLikeCount && ids.length === 1 ? { likeCount: await fetchLikeCount(item.id) } : {}),
|
|
113
|
-
...(addResumeTimeSeconds ? { resumeTime: resumeTimeData?.
|
|
113
|
+
...(addResumeTimeSeconds ? { resumeTime: resumeTimeData?.get(item.id) } : {}),
|
|
114
114
|
...(addNavigateTo ? { navigateTo: navigateToData?.[item.id] } : {}),
|
|
115
115
|
...(addAwards ? { awards: awards?.[item.id].awards || [] } : {}),
|
|
116
116
|
})
|
|
@@ -250,12 +250,12 @@ export async function getNavigateToForPlaylists(data, { dataField = null } = {})
|
|
|
250
250
|
|
|
251
251
|
const allItemsCompleted = accessibleItems.every((i) => {
|
|
252
252
|
const itemId = i.content_id
|
|
253
|
-
const progress = progressOnItems
|
|
253
|
+
const progress = progressOnItems.get(itemId)
|
|
254
254
|
return progress && progress === 'completed'
|
|
255
255
|
})
|
|
256
256
|
let nextItem = accessibleItems[0] ?? playlist.items[0] ?? null
|
|
257
257
|
if (!allItemsCompleted) {
|
|
258
|
-
const lastItemProgress = progressOnItems
|
|
258
|
+
const lastItemProgress = progressOnItems.get(playlist.last_engaged_on)
|
|
259
259
|
const index = accessibleItems.findIndex((i) => i.content_id === playlist.last_engaged_on)
|
|
260
260
|
if (lastItemProgress === 'completed') {
|
|
261
261
|
nextItem = accessibleItems[index + 1] ?? nextItem
|
|
@@ -46,7 +46,7 @@ export async function getNavigateToForMethod(data) {
|
|
|
46
46
|
const {content, collection} = tuple
|
|
47
47
|
|
|
48
48
|
const findFirstIncomplete = (ids, progresses) =>
|
|
49
|
-
ids.find(id => progresses
|
|
49
|
+
ids.find(id => progresses.get(id) !== STATE_COMPLETED) || ids[0]
|
|
50
50
|
|
|
51
51
|
const findChildById = (children, id) =>
|
|
52
52
|
children?.find(child => child.id === Number(id)) || null
|
|
@@ -132,7 +132,7 @@ export async function getNavigateTo(data, collection = null) {
|
|
|
132
132
|
} else {
|
|
133
133
|
const childrenStates = await getProgressStateByIds(childrenIds, collection)
|
|
134
134
|
const lastInteracted = await getLastInteractedOf(childrenIds, collection)
|
|
135
|
-
const lastInteractedStatus = childrenStates
|
|
135
|
+
const lastInteractedStatus = childrenStates.get(lastInteracted)
|
|
136
136
|
|
|
137
137
|
if (['course', 'skill-pack', 'song-tutorial'].includes(content.type)) {
|
|
138
138
|
if (lastInteractedStatus === STATE_STARTED) {
|
|
@@ -168,7 +168,7 @@ export async function getNavigateTo(data, collection = null) {
|
|
|
168
168
|
firstChildren.map((child) => child.id),
|
|
169
169
|
collection
|
|
170
170
|
)
|
|
171
|
-
if (childrenStates
|
|
171
|
+
if (childrenStates.get(lastInteractedChildId) === STATE_COMPLETED) {
|
|
172
172
|
// TODO: course collections have an extra situation where we need to jump to the next course if all lessons in the last engaged course are completed
|
|
173
173
|
}
|
|
174
174
|
let lastInteractedChildNavToData = await getNavigateTo(firstChildren, collection)
|
|
@@ -292,12 +292,12 @@ async function getById(contentId, collection, dataKey, defaultValue) {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
async function getByIds(contentIds, collection, dataKey, defaultValue) {
|
|
295
|
-
if (contentIds.length === 0) return
|
|
295
|
+
if (contentIds.length === 0) return new Map()
|
|
296
296
|
|
|
297
|
-
const progress =
|
|
297
|
+
const progress = new Map(contentIds.map((id) => [id, defaultValue]))
|
|
298
298
|
await db.contentProgress.getSomeProgressByContentIds(normalizeContentIds(contentIds), normalizeCollection(collection)).then((r) => {
|
|
299
299
|
r.data.forEach((p) => {
|
|
300
|
-
progress
|
|
300
|
+
progress.set(p.content_id, p[dataKey] ?? defaultValue)
|
|
301
301
|
})
|
|
302
302
|
})
|
|
303
303
|
return progress
|
|
@@ -750,7 +750,7 @@ function averageProgressesFor(hierarchy, contentId, progressData, depth = 1) {
|
|
|
750
750
|
if (!parentId) return {}
|
|
751
751
|
|
|
752
752
|
const parentChildProgress = hierarchy?.children?.[parentId]?.map((childId) => {
|
|
753
|
-
return progressData
|
|
753
|
+
return progressData.get(childId) ?? 0
|
|
754
754
|
})
|
|
755
755
|
const avgParentProgress =
|
|
756
756
|
parentChildProgress.length > 0
|
|
@@ -180,7 +180,7 @@ async function getCompletedChildren(content, contentType) {
|
|
|
180
180
|
} else if (content.lesson_count > 0) {
|
|
181
181
|
const lessonIds = getLeafNodes(content)
|
|
182
182
|
const progressOnItems = await getProgressStateByIds(lessonIds)
|
|
183
|
-
completedChildren =
|
|
183
|
+
completedChildren = Array.from(progressOnItems.values()).filter(
|
|
184
184
|
(value) => value === 'completed'
|
|
185
185
|
).length
|
|
186
186
|
allChildren = lessonIds.length
|
|
@@ -892,19 +892,20 @@ export async function restoreUserActivity(id) {
|
|
|
892
892
|
}
|
|
893
893
|
|
|
894
894
|
export function findIncompleteLesson(progressOnItems, currentContentId, contentType) {
|
|
895
|
-
const
|
|
895
|
+
const isMap = progressOnItems instanceof Map
|
|
896
|
+
const ids = isMap ? Array.from(progressOnItems.keys()) : Object.keys(progressOnItems).map(Number)
|
|
897
|
+
const getProgress = (id) => isMap ? progressOnItems.get(id) : progressOnItems[id]
|
|
898
|
+
|
|
896
899
|
if (contentType === 'guided-course' || contentType === COLLECTION_TYPE.LEARNING_PATH) {
|
|
897
|
-
|
|
898
|
-
return ids.find((id) => progressOnItems[id] !== 'completed') || ids.at(0)
|
|
900
|
+
return ids.find((id) => getProgress(id) !== 'completed') || ids.at(0)
|
|
899
901
|
}
|
|
900
902
|
|
|
901
|
-
// For other types, find next incomplete after current
|
|
902
903
|
const currentIndex = ids.indexOf(Number(currentContentId))
|
|
903
904
|
if (currentIndex === -1) return null
|
|
904
905
|
|
|
905
906
|
for (let i = currentIndex + 1; i < ids.length; i++) {
|
|
906
907
|
const id = ids[i]
|
|
907
|
-
if (
|
|
908
|
+
if (getProgress(id) !== 'completed') {
|
|
908
909
|
return id
|
|
909
910
|
}
|
|
910
911
|
}
|