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 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)
File without changes
package/docs/index.html CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.161",
3
+ "version": "1.0.163",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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 "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
150
- (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
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;
File without changes
File without changes
File without changes
File without changes