musora-content-services 1.0.161 → 1.0.163
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 +4 -0
- package/docs/config.js.html +0 -0
- package/docs/index.html +0 -0
- package/docs/module-Config.html +0 -0
- package/docs/module-Railcontent-Services.html +0 -0
- package/docs/module-Sanity-Services.html +0 -0
- package/docs/railcontent.js.html +0 -0
- package/docs/sanity.js.html +0 -0
- package/package.json +1 -1
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +24 -3
- package/src/services/dataContext.js +0 -0
- package/src/services/lastUpdated.js +0 -0
- package/src/services/railcontent.js +0 -0
- package/src/services/userPermissions.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/contentProgress.test.js +13 -2
- package/test/initializeTests.js +0 -0
- package/test/lastUpdated.test.js +0 -0
- package/test/sanityQueryService.test.js +0 -0
- package/test/userPermissions.test.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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
|
+
### [1.0.163](https://github.com/railroadmedia/musora-content-services/compare/v1.0.162...v1.0.163) (2024-11-08)
|
|
6
|
+
|
|
7
|
+
### [1.0.162](https://github.com/railroadmedia/musora-content-services/compare/v1.0.161...v1.0.162) (2024-11-08)
|
|
8
|
+
|
|
5
9
|
### [1.0.161](https://github.com/railroadmedia/musora-content-services/compare/v1.0.152...v1.0.161) (2024-11-08)
|
|
6
10
|
|
|
7
11
|
### [1.0.160](https://github.com/railroadmedia/musora-content-services/compare/v1.0.159...v1.0.160) (2024-11-08)
|
package/docs/config.js.html
CHANGED
|
File without changes
|
package/docs/index.html
CHANGED
|
File without changes
|
package/docs/module-Config.html
CHANGED
|
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
|
package/package.json
CHANGED
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
contentStatusCompleted,
|
|
16
16
|
contentStatusReset,
|
|
17
|
+
getAllCompleted,
|
|
18
|
+
getAllStarted,
|
|
17
19
|
getProgressPercentage,
|
|
18
20
|
getProgressPercentageByIds,
|
|
19
21
|
getProgressState,
|
|
@@ -200,6 +202,8 @@ declare module 'musora-content-services' {
|
|
|
200
202
|
fetchUserPermissionsData,
|
|
201
203
|
fetchUserPlaylists,
|
|
202
204
|
fetchWorkouts,
|
|
205
|
+
getAllCompleted,
|
|
206
|
+
getAllStarted,
|
|
203
207
|
getProgressPercentage,
|
|
204
208
|
getProgressPercentageByIds,
|
|
205
209
|
getProgressState,
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
contentStatusCompleted,
|
|
16
16
|
contentStatusReset,
|
|
17
|
+
getAllCompleted,
|
|
18
|
+
getAllStarted,
|
|
17
19
|
getProgressPercentage,
|
|
18
20
|
getProgressPercentageByIds,
|
|
19
21
|
getProgressState,
|
|
@@ -199,6 +201,8 @@ export {
|
|
|
199
201
|
fetchUserPermissionsData,
|
|
200
202
|
fetchUserPlaylists,
|
|
201
203
|
fetchWorkouts,
|
|
204
|
+
getAllCompleted,
|
|
205
|
+
getAllStarted,
|
|
202
206
|
getProgressPercentage,
|
|
203
207
|
getProgressPercentageByIds,
|
|
204
208
|
getProgressState,
|
|
File without changes
|
|
@@ -43,6 +43,26 @@ export async function getProgressStateByIds(contentIds) {
|
|
|
43
43
|
return progress;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export async function getAllStarted() {
|
|
47
|
+
const data = await dataContext.getData();
|
|
48
|
+
let ids = Object.keys(data).filter(function (key) {
|
|
49
|
+
return data[parseInt(key)][DATA_KEY_STATUS] === STATE_STARTED;
|
|
50
|
+
}).map(function (key) {
|
|
51
|
+
return parseInt(key);
|
|
52
|
+
});
|
|
53
|
+
return ids;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function getAllCompleted() {
|
|
57
|
+
const data = await dataContext.getData();
|
|
58
|
+
let ids = Object.keys(data).filter(function (key) {
|
|
59
|
+
return data[parseInt(key)][DATA_KEY_STATUS] === STATE_COMPLETED;
|
|
60
|
+
}).map(function (key) {
|
|
61
|
+
return parseInt(key);
|
|
62
|
+
});
|
|
63
|
+
return ids;
|
|
64
|
+
}
|
|
65
|
+
|
|
46
66
|
export async function getResumeTimeSeconds(contentId) {
|
|
47
67
|
let data = await dataContext.getData();
|
|
48
68
|
return data[contentId]?.[DATA_KEY_RESUME_TIME] ?? 0;
|
|
@@ -146,9 +166,10 @@ function getMediaTypeId(mediaType, mediaCategory) {
|
|
|
146
166
|
}
|
|
147
167
|
|
|
148
168
|
function uuidv4() {
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
169
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
170
|
+
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
171
|
+
return v.toString(16);
|
|
172
|
+
});
|
|
152
173
|
}
|
|
153
174
|
|
|
154
175
|
function bubbleProgress(hierarchy, contentId, localContext) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getProgressPercentage,
|
|
3
3
|
dataContext,
|
|
4
4
|
recordWatchSession,
|
|
5
|
-
getProgressPercentageByIds, getProgressState, getProgressStateByIds
|
|
5
|
+
getProgressPercentageByIds, getProgressState, getProgressStateByIds, getAllStarted, getAllCompleted
|
|
6
6
|
} from "../src/services/contentProgress";
|
|
7
7
|
import {initializeTestService} from "./initializeTests";
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ describe('contentProgressDataContext', function () {
|
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
initializeTestService();
|
|
17
17
|
mock = jest.spyOn(dataContext, 'fetchData');
|
|
18
|
-
var json = JSON.parse(`{"version":${testVersion},"data":{"234191":{"s":"started","p":6,"t":20},"233955":{"s":"started","p":1}}}`);
|
|
18
|
+
var json = JSON.parse(`{"version":${testVersion},"data":{"234191":{"s":"started","p":6,"t":20},"233955":{"s":"started","p":1},"259426":{"s":"completed","p":100}}}`);
|
|
19
19
|
mock.mockImplementation(() => json);
|
|
20
20
|
|
|
21
21
|
});
|
|
@@ -47,6 +47,17 @@ describe('contentProgressDataContext', function () {
|
|
|
47
47
|
expect(result[120402]).toBe("");
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
test('getAllStarted', async () => {
|
|
51
|
+
let result = await getAllStarted();
|
|
52
|
+
expect(result).toContain(234191);
|
|
53
|
+
expect(result).toContain(233955);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('getAllCompleted', async () => {
|
|
57
|
+
let result = await getAllCompleted();
|
|
58
|
+
expect(result).toContain(259426);
|
|
59
|
+
});
|
|
60
|
+
|
|
50
61
|
test('progressBubbling', async () => {
|
|
51
62
|
let mock2 = jest.spyOn(railContentModule, 'postRecordWatchSession');
|
|
52
63
|
let serverVersion = 2;
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
package/test/lastUpdated.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|