musora-content-services 2.21.0 → 2.21.2

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,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.2](https://github.com/railroadmedia/musora-content-services/compare/v2.21.1...v2.21.2) (2025-07-14)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **systest:** patch contentAggregator ([#342](https://github.com/railroadmedia/musora-content-services/issues/342)) ([4a1906e](https://github.com/railroadmedia/musora-content-services/commit/4a1906ed8e5cfc3cebf3e044d4eb35213d18ebe1))
11
+
12
+ ### [2.21.1](https://github.com/railroadmedia/musora-content-services/compare/v2.21.0...v2.21.1) (2025-07-14)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * track correct amount of video watch time ([07d31c8](https://github.com/railroadmedia/musora-content-services/commit/07d31c802164b0625b5e72ce78e618fc5d12ecaf))
18
+ * track correct amount of video watch time ([41a0d0b](https://github.com/railroadmedia/musora-content-services/commit/41a0d0b82d73183c52db7b510d00bbf7838554d0))
19
+
5
20
  ## [2.21.0](https://github.com/railroadmedia/musora-content-services/compare/v2.20.0...v2.21.0) (2025-07-12)
6
21
 
7
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.21.0",
3
+ "version": "2.21.2",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -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
- ids = [...ids, ...parent[dataField].map(item => item?.id).filter(Boolean)]
40
+ items = [...items, ...parent[dataField]]
42
41
  }
43
42
  } else {
44
- ids = data[dataField].map(item => item?.id).filter(Boolean);
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(dataMap) : Promise.resolve(null),
61
+ (addNextLesson || addLastInteractedParent) ? getNextLesson(items) : Promise.resolve(null),
76
62
  ])
77
63
 
78
64
  const addContext = async (item) => ({
@@ -18,6 +18,8 @@ const DATA_KEY_LAST_UPDATED_TIME = 'u'
18
18
 
19
19
  export let dataContext = new DataContext(ContentProgressVersionKey, fetchContentProgress)
20
20
 
21
+ let sessionData = []
22
+
21
23
  export async function getProgressPercentage(contentId) {
22
24
  return getById(contentId, DATA_KEY_PROGRESS, 0)
23
25
  }
@@ -42,12 +44,12 @@ export async function getResumeTimeSecondsByIds(contentIds) {
42
44
  return getByIds(contentIds, DATA_KEY_RESUME_TIME, 0)
43
45
  }
44
46
 
45
- export async function getNextLesson(dataMap)
47
+ export async function getNextLesson(data)
46
48
  {
47
49
  let nextLessonData = {}
48
50
 
49
- for (const content of dataMap) {
50
-
51
+ for (const content of data) {
52
+ const children = content.children?.map(child => child.id) ?? []
51
53
  //only calculate nextLesson if needed, based on content type
52
54
  if (!getNextLessonLessonParentTypes.includes(content.type)) {
53
55
  nextLessonData[content.id] = null
@@ -56,15 +58,15 @@ export async function getNextLesson(dataMap)
56
58
  //return first child if parent-content is complete or no progress
57
59
  const contentState = await getProgressState(content.id)
58
60
  if (contentState !== STATE_STARTED) {
59
- nextLessonData[content.id] = content.children[0]
61
+ nextLessonData[content.id] = children[0]
60
62
 
61
63
  } else {
62
64
  //if content in progress
63
65
 
64
- const childrenStates = await getProgressStateByIds(content.children)
66
+ const childrenStates = await getProgressStateByIds(children)
65
67
 
66
68
  //calculate last_engaged
67
- const lastInteracted = await getLastInteractedOf(content.children)
69
+ const lastInteracted = await getLastInteractedOf(children)
68
70
  const lastInteractedStatus = childrenStates[lastInteracted]
69
71
 
70
72
  //different nextLesson behaviour for different content types
@@ -383,10 +385,14 @@ export async function recordWatchSession(
383
385
  }
384
386
 
385
387
  try {
386
- await recordUserPractice({ content_id: contentId, duration_seconds: Math.ceil(secondsPlayed) })
388
+ //TODO: Good enough for Alpha, Refine in reliability improvements
389
+ sessionData[sessionId] = sessionData[sessionId] || {}
390
+ const secondsSinceLastUpdate = Math.ceil(secondsPlayed - (sessionData[sessionId][contentId] ?? 0))
391
+ await recordUserPractice({ content_id: contentId, duration_seconds: secondsSinceLastUpdate })
387
392
  } catch (error) {
388
393
  console.error('Failed to record user practice:', error)
389
394
  }
395
+ sessionData[sessionId][contentId] = secondsPlayed
390
396
 
391
397
  await dataContext.update(
392
398
  async function (localContext) {
File without changes
@@ -1,8 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(rg:*)"
5
- ],
6
- "deny": []
7
- }
8
- }