musora-content-services 1.0.25 → 1.0.27
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/package.json +1 -1
- package/src/services/railcontent.js +7 -2
- package/src/services/sanity.js +19 -17
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.27](https://github.com/railroadmedia/musora-content-services/compare/v1.0.26...v1.0.27) (2024-08-14)
|
|
6
|
+
|
|
7
|
+
### [1.0.26](https://github.com/railroadmedia/musora-content-services/compare/v1.0.25...v1.0.26) (2024-08-14)
|
|
8
|
+
|
|
5
9
|
### [1.0.25](https://github.com/railroadmedia/musora-content-services/compare/v1.0.24...v1.0.25) (2024-08-14)
|
|
6
10
|
|
|
7
11
|
### [1.0.24](https://github.com/railroadmedia/musora-content-services/compare/v1.0.23...v1.0.24) (2024-08-14)
|
package/package.json
CHANGED
|
@@ -18,16 +18,21 @@ const { globalConfig } = require('./config');
|
|
|
18
18
|
*/
|
|
19
19
|
export async function fetchCurrentSongComplete(content_id) {
|
|
20
20
|
const url = `/content/user_progress/${globalConfig.railcontentConfig.userId}?content_ids[]=${content_id}`;
|
|
21
|
+
console.log('Request URL:', url); // Debugging log
|
|
21
22
|
|
|
22
23
|
const headers = {
|
|
23
24
|
'Content-Type': 'application/json',
|
|
24
25
|
'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
|
|
25
26
|
};
|
|
27
|
+
|
|
26
28
|
try {
|
|
27
29
|
const response = await fetch(url, { headers });
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
32
|
+
}
|
|
28
33
|
const result = await response.json();
|
|
29
|
-
if(result){
|
|
30
|
-
console.log('result', result
|
|
34
|
+
if (result) {
|
|
35
|
+
console.log('API result:', result);
|
|
31
36
|
return result[globalConfig.railcontentConfig.userId];
|
|
32
37
|
}
|
|
33
38
|
} catch (error) {
|
package/src/services/sanity.js
CHANGED
|
@@ -31,26 +31,28 @@ export async function fetchSongById(songId) {
|
|
|
31
31
|
railcontent_id,
|
|
32
32
|
"resources": resource[]{resource_url, resource_name},
|
|
33
33
|
}`;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.log('
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const songData = await fetchSanity(query, false);
|
|
37
|
+
const currentSongComplete = await fetchCurrentSongComplete(songId);
|
|
38
|
+
|
|
39
|
+
if (songData && currentSongComplete) {
|
|
40
|
+
console.log('currentSongComplete', currentSongComplete);
|
|
41
|
+
songData.completed = currentSongComplete.state !== "not started";
|
|
42
|
+
songData.progress_percent = currentSongComplete.percent.toString();
|
|
43
|
+
} else {
|
|
44
|
+
console.log('no currentSongComplete', currentSongComplete);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log('all songData', songData);
|
|
48
|
+
return songData;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error fetching song by ID:', error);
|
|
51
|
+
return null;
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
console.log('all songData', songData)
|
|
51
|
-
return songData;
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
|
|
54
56
|
/**
|
|
55
57
|
* Fetch all artists with lessons available for a specific brand.
|
|
56
58
|
*
|