musora-content-services 2.10.0 → 2.11.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 +15 -0
- package/docs/ContentOrganization.html +0 -0
- package/docs/Gamification.html +0 -0
- package/docs/UserManagementSystem.html +0 -0
- package/docs/api_types.js.html +0 -0
- package/docs/config.js.html +0 -0
- package/docs/content-org_content-org.js.html +0 -0
- package/docs/content-org_playlists-types.js.html +0 -0
- package/docs/content-org_playlists.js.html +0 -0
- package/docs/content.js.html +0 -0
- package/docs/gamification_awards.js.html +0 -0
- package/docs/gamification_gamification.js.html +0 -0
- package/docs/gamification_types.js.html +0 -0
- package/docs/global.html +0 -0
- package/docs/index.html +0 -0
- package/docs/module-Awards.html +0 -0
- package/docs/module-Config.html +0 -0
- package/docs/module-Content-Services-V2.html +0 -0
- package/docs/module-Interests.html +0 -0
- package/docs/module-Permissions.html +0 -0
- package/docs/module-Playlists.html +0 -0
- package/docs/module-Railcontent-Services.html +0 -0
- package/docs/module-Sanity-Services.html +0 -0
- package/docs/module-Sessions.html +0 -0
- package/docs/module-UserActivity.html +0 -0
- package/docs/module-UserManagement.html +0 -0
- package/docs/module-UserNotifications.html +0 -0
- package/docs/module-UserProfile.html +0 -0
- package/docs/railcontent.js.html +0 -0
- package/docs/sanity.js.html +0 -0
- package/docs/userActivity.js.html +0 -0
- package/docs/user_interests.js.html +0 -0
- package/docs/user_management.js.html +0 -0
- package/docs/user_notifications.js.html +0 -0
- package/docs/user_permissions.js.html +0 -0
- package/docs/user_profile.js.html +0 -0
- package/docs/user_sessions.js.html +0 -0
- package/docs/user_types.js.html +0 -0
- package/docs/user_user-management-system.js.html +0 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +1 -1
- package/src/index.d.ts +0 -0
- package/src/index.js +0 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/railcontent.js +4 -1
- package/src/services/sanity.js +6 -2
- package/src/services/user/notifications.js +0 -0
- package/src/services/userActivity.js +24 -14
- package/docs/module-Content-Services.html +0 -763
- package/docs/module-UserChat.html +0 -410
- package/docs/user_chat.js.html +0 -98
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.11.0](https://github.com/railroadmedia/musora-content-services/compare/v2.10.0...v2.11.0) (2025-06-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **MU2-698:** change extra minutes from 15 to 30 ([ccb1a96](https://github.com/railroadmedia/musora-content-services/commit/ccb1a9682c0d75a61743645434fb1ae5398ca509))
|
|
11
|
+
* **MU2-712:** Add live_event_start_time and live_event_end_time on fetchUpcomingEvents ([0de3f8e](https://github.com/railroadmedia/musora-content-services/commit/0de3f8ea68a2a8d29d122f6adf2d893669d3bd25))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* Duplicate practice per day in cache ([d44e0f6](https://github.com/railroadmedia/musora-content-services/commit/d44e0f6a384e78b5d515bcafc99cba30b24a535d))
|
|
17
|
+
* **MU2-693:** Fix cache(data versioning) on user practices ([ddc0d3b](https://github.com/railroadmedia/musora-content-services/commit/ddc0d3b3bd180c0f51241112ce7ba2094ff71c8c))
|
|
18
|
+
* User practice cache generation after one practice is restored ([dfb9e27](https://github.com/railroadmedia/musora-content-services/commit/dfb9e271e9efcb18b1d866935e0eb4acb7317b4b))
|
|
19
|
+
|
|
5
20
|
## [2.10.0](https://github.com/railroadmedia/musora-content-services/compare/v2.9.5...v2.10.0) (2025-06-23)
|
|
6
21
|
|
|
7
22
|
|
|
File without changes
|
package/docs/Gamification.html
CHANGED
|
File without changes
|
|
File without changes
|
package/docs/api_types.js.html
CHANGED
|
File without changes
|
package/docs/config.js.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/content.js.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/global.html
CHANGED
|
File without changes
|
package/docs/index.html
CHANGED
|
File without changes
|
package/docs/module-Awards.html
CHANGED
|
File without changes
|
package/docs/module-Config.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/railcontent.js.html
CHANGED
|
File without changes
|
package/docs/sanity.js.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/user_types.js.html
CHANGED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -416,7 +416,7 @@ export let contentTypeConfig = {
|
|
|
416
416
|
'"lesson_count": coalesce(count(child[]->.child[]->), 0)',
|
|
417
417
|
'xp',
|
|
418
418
|
`"description": ${descriptionField}`,
|
|
419
|
-
'"instructors": instructor[]->name',
|
|
419
|
+
'"instructors": instructor[]->{ "id": railcontent_id, name, "thumbnail_url": thumbnail_url.asset->url }',
|
|
420
420
|
'"logo_image_url": logo_image_url.asset->url',
|
|
421
421
|
'total_xp',
|
|
422
422
|
`"children": child[]->{
|
package/src/index.d.ts
CHANGED
|
File without changes
|
package/src/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -755,7 +755,7 @@ export async function reportComment(commentId, issue) {
|
|
|
755
755
|
return await postDataHandler(url, data)
|
|
756
756
|
}
|
|
757
757
|
|
|
758
|
-
export async function fetchUserPractices(
|
|
758
|
+
export async function fetchUserPractices(currentVersion = 0, { userId } = {}) {
|
|
759
759
|
const params = new URLSearchParams();
|
|
760
760
|
if (userId) params.append('user_id', userId);
|
|
761
761
|
const query = params.toString() ? `?${params.toString()}` : '';
|
|
@@ -763,6 +763,9 @@ export async function fetchUserPractices({ currentVersion, userId } = {}) {
|
|
|
763
763
|
const response = await fetchDataHandler(url, currentVersion);
|
|
764
764
|
const { data, version } = response;
|
|
765
765
|
const userPractices = data;
|
|
766
|
+
if(!userPractices ) {
|
|
767
|
+
return { data: { practices: {} }, version };
|
|
768
|
+
}
|
|
766
769
|
|
|
767
770
|
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
768
771
|
|
package/src/services/sanity.js
CHANGED
|
@@ -405,6 +405,8 @@ export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {})
|
|
|
405
405
|
"type": _type,
|
|
406
406
|
web_url_path,
|
|
407
407
|
"permission_id": permission[]->railcontent_id,
|
|
408
|
+
live_event_start_time,
|
|
409
|
+
live_event_end_time,
|
|
408
410
|
"isLive": live_event_start_time <= '${now}' && live_event_end_time >= '${now}'`
|
|
409
411
|
const query = buildRawQuery(
|
|
410
412
|
`defined(live_event_start_time) && (!defined(live_event_end_time) || live_event_end_time >= '${now}' ) && brand == '${brand}' && published_on > '${now}' && status == 'scheduled'`,
|
|
@@ -1502,6 +1504,7 @@ export async function fetchPackAll(railcontentId, type = 'pack') {
|
|
|
1502
1504
|
}
|
|
1503
1505
|
|
|
1504
1506
|
export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
1507
|
+
const LIVE_EXTRA_MINUTES = 30;
|
|
1505
1508
|
//calendarIDs taken from addevent.php
|
|
1506
1509
|
// TODO import instructor calendars to Sanity
|
|
1507
1510
|
let defaultCalendarID = ''
|
|
@@ -1523,8 +1526,9 @@ export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
|
1523
1526
|
}
|
|
1524
1527
|
let startDateTemp = new Date()
|
|
1525
1528
|
let endDateTemp = new Date()
|
|
1526
|
-
|
|
1527
|
-
|
|
1529
|
+
|
|
1530
|
+
startDateTemp = new Date(startDateTemp.setMinutes(startDateTemp.getMinutes() + LIVE_EXTRA_MINUTES))
|
|
1531
|
+
endDateTemp = new Date(endDateTemp.setMinutes(endDateTemp.getMinutes() - LIVE_EXTRA_MINUTES))
|
|
1528
1532
|
|
|
1529
1533
|
// See LiveStreamEventService.getCurrentOrNextLiveEvent for some nice complicated logic which I don't think is actually importart
|
|
1530
1534
|
// this has some +- on times
|
|
File without changes
|
|
@@ -55,7 +55,7 @@ function getIndefiniteArticle(streak) {
|
|
|
55
55
|
|
|
56
56
|
export async function getUserPractices(userId = globalConfig.sessionConfig.userId) {
|
|
57
57
|
if (userId !== globalConfig.sessionConfig.userId) {
|
|
58
|
-
let data = await fetchUserPractices({ userId })
|
|
58
|
+
let data = await fetchUserPractices(0, { userId: userId })
|
|
59
59
|
return data?.['data']?.[DATA_KEY_PRACTICES] ?? {}
|
|
60
60
|
} else {
|
|
61
61
|
let data = await userActivityContext.getData()
|
|
@@ -376,20 +376,30 @@ export async function removeUserPractice(id) {
|
|
|
376
376
|
export async function restoreUserPractice(id) {
|
|
377
377
|
let url = `/api/user/practices/v1/practices/restore${buildQueryString([id])}`
|
|
378
378
|
const response = await fetchHandler(url, 'put')
|
|
379
|
-
if (response?.data) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
379
|
+
if (response?.data?.length) {
|
|
380
|
+
const restoredPractice = response.data.find((p) => p.id === id)
|
|
381
|
+
if (restoredPractice) {
|
|
382
|
+
await userActivityContext.updateLocal(async function (localContext) {
|
|
383
|
+
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
384
|
+
const utcDate = new Date(restoredPractice.day)
|
|
385
|
+
const localDate = convertToTimeZone(utcDate, userTimeZone)
|
|
386
|
+
const date =
|
|
387
|
+
localDate.getFullYear() + '-' +
|
|
388
|
+
String(localDate.getMonth() + 1).padStart(2, '0') + '-' +
|
|
389
|
+
String(localDate.getDate()).padStart(2, '0')
|
|
390
|
+
if (localContext.data[DATA_KEY_PRACTICES][date]) {
|
|
391
|
+
localContext.data[DATA_KEY_PRACTICES][date] = []
|
|
392
|
+
}
|
|
393
|
+
response.data.forEach((restoredPractice) => {
|
|
394
|
+
localContext.data[DATA_KEY_PRACTICES][date].push({
|
|
395
|
+
id: restoredPractice.id,
|
|
396
|
+
duration_seconds: restoredPractice.duration_seconds,
|
|
397
|
+
})
|
|
398
|
+
})
|
|
389
399
|
})
|
|
390
|
-
}
|
|
400
|
+
}
|
|
391
401
|
}
|
|
392
|
-
const formattedMeta = await formatPracticeMeta(response.data)
|
|
402
|
+
const formattedMeta = await formatPracticeMeta(response.data || [])
|
|
393
403
|
const practiceDuration = formattedMeta.reduce(
|
|
394
404
|
(total, practice) => total + (practice.duration || 0),
|
|
395
405
|
0
|
|
@@ -603,7 +613,7 @@ function getStreaksAndMessage(practices) {
|
|
|
603
613
|
async function getUserPracticeIds(day = new Date().toISOString().split('T')[0], userId = null) {
|
|
604
614
|
let practices = {}
|
|
605
615
|
if (userId !== globalConfig.sessionConfig.userId) {
|
|
606
|
-
let data = await fetchUserPractices({ userId })
|
|
616
|
+
let data = await fetchUserPractices(0, { userId: userId })
|
|
607
617
|
practices = data?.['data']?.[DATA_KEY_PRACTICES] ?? {}
|
|
608
618
|
} else {
|
|
609
619
|
let data = await userActivityContext.getData()
|