musora-content-services 2.73.0 → 2.74.0

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,13 @@
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.74.0](https://github.com/railroadmedia/musora-content-services/compare/v2.73.0...v2.74.0) (2025-11-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * update fetch learning path lessons ([#551](https://github.com/railroadmedia/musora-content-services/issues/551)) ([a434076](https://github.com/railroadmedia/musora-content-services/commit/a434076a8281af61043c1ec3e09798e7981ff8f3))
11
+
5
12
  ## [2.73.0](https://github.com/railroadmedia/musora-content-services/compare/v2.72.1...v2.73.0) (2025-11-06)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.73.0",
3
+ "version": "2.74.0",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -66,11 +66,12 @@ export async function updateActivePath(brand: string) {
66
66
  * @returns {string} result.thumbnail - Optional thumbnail URL for the learning path.
67
67
  * @returns {string} result.title - The title of the learning path.
68
68
  * @returns {boolean} result.is_active_learning_path - Whether the learning path is currently active.
69
- * @returns {Array} result.all_lessons - Array of all lessons.
69
+ * @returns {Array} result.children - Array of all lessons.
70
70
  * @returns {Array} result.upcoming_lessons - Array of upcoming/additional lessons.
71
71
  * @returns {Array} result.todays_lessons - Array of today's lessons (max 3).
72
72
  * @returns {Array} result.next_learning_path_lessons - Array of next lessons to be taken.
73
73
  * @returns {Array} result.completed_lessons - Array of completed lessons.
74
+ * @returns {Array} result.previous_learning_path_todays - Array of completed lessons.
74
75
  */
75
76
  export async function fetchLearningPathLessons(
76
77
  learningPathId: number,
@@ -86,21 +87,30 @@ export async function fetchLearningPathLessons(
86
87
  addProgressStatus: true,
87
88
  addProgressPercentage: true,
88
89
  }
90
+
89
91
  const lessons = await addContextToContent(() => learningPath.children, addContextParameters)
90
92
  const isActiveLearningPath = (dailySession?.active_learning_path_id || 0) == learningPathId
93
+ const manipulatedLessons = lessons.map((lesson: any) => {
94
+ return { ...lesson, type: 'learning-path-lesson-v2', parent_id: learningPathId }
95
+ })
96
+
97
+ if (!isActiveLearningPath) {
98
+ return {
99
+ ...learningPath,
100
+ is_active_learning_path: isActiveLearningPath,
101
+ children: manipulatedLessons,
102
+ }
103
+ }
104
+
91
105
  const todayContentIds = dailySession.daily_session[0]?.content_ids || []
92
106
  const nextContentIds = dailySession.daily_session[1]?.content_ids || []
93
107
  const completedLessons = []
94
108
  let todaysLessons = []
95
- let nextLPLessons = []
96
109
  const upcomingLessons = []
97
- const lessonIds = lessons.map((lesson: any) => lesson.id).filter(Boolean)
98
110
 
99
- lessons.forEach((lesson: any) => {
111
+ manipulatedLessons.forEach((lesson: any) => {
100
112
  if (todayContentIds.includes(lesson.id)) {
101
113
  todaysLessons.push(lesson)
102
- } else if (nextContentIds.includes(lesson.id)) {
103
- nextLPLessons.push(lesson)
104
114
  } else if (lesson.progressStatus === 'completed') {
105
115
  completedLessons.push(lesson)
106
116
  } else {
@@ -108,15 +118,20 @@ export async function fetchLearningPathLessons(
108
118
  }
109
119
  })
110
120
 
121
+ let previousLearnigPathTodays = []
111
122
  if (todaysLessons.length == 0 && nextLPLessons.length > 0) {
112
123
  // Daily sessions first lessons are not part of the active learning path, but next lessons are
113
124
  // load todays lessons from previous learning path
114
- todaysLessons = await addContextToContent(
125
+ previousLearnigPathTodays = await addContextToContent(
115
126
  fetchByRailContentIds,
116
127
  todayContentIds,
117
128
  addContextParameters
118
129
  )
119
- } else if (nextContentIds.length > 0 && nextLPLessons.length == 0 && todaysLessons.length > 0) {
130
+ } else if (
131
+ nextContentIds.length > 0 &&
132
+ todaysLessons.length < 3 &&
133
+ upcomingLessons.length === 0
134
+ ) {
120
135
  // Daily sessions first lessons are the active learning path and the next lessons are not
121
136
  // load next lessons from next learning path
122
137
  nextLPLessons = await addContextToContent(
@@ -129,10 +144,11 @@ export async function fetchLearningPathLessons(
129
144
  return {
130
145
  ...learningPath,
131
146
  is_active_learning_path: isActiveLearningPath,
132
- children: lessons,
147
+ children: manipulatedLessons,
133
148
  upcoming_lessons: upcomingLessons,
134
149
  todays_lessons: todaysLessons,
135
150
  next_learning_path_lessons: nextLPLessons,
136
151
  completed_lessons: completedLessons,
152
+ previous_learning_path_todays: previousLearnigPathTodays,
137
153
  }
138
154
  }