musora-content-services 2.21.2 → 2.21.4
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/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +10 -0
- package/src/services/forum.js +38 -16
- package/src/services/gamification/awards.js +1 -519
- package/src/services/imageSRCVerify.js +0 -0
- package/src/services/sanity.js +9 -7
- package/src/services/userActivity.js +10 -8
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -73,18 +73,19 @@ export async function fetchSongById(documentId) {
|
|
|
73
73
|
* @returns {Promise<Object|null>}
|
|
74
74
|
*/
|
|
75
75
|
export async function fetchLeaving(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
76
|
+
const today = new Date()
|
|
77
|
+
const isoDateOnly = today.toISOString().split('T')[0]
|
|
78
|
+
const filterString = `brand == '${brand}' && quarter_removed > '${isoDateOnly}'`
|
|
78
79
|
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
79
80
|
const sortOrder = {
|
|
80
|
-
sortOrder: 'published_on desc, id desc',
|
|
81
|
+
sortOrder: 'quarter_removed asc, published_on desc, id desc',
|
|
81
82
|
start: startEndOrder['start'],
|
|
82
83
|
end: startEndOrder['end'],
|
|
83
84
|
}
|
|
84
85
|
const query = await buildQuery(
|
|
85
86
|
filterString,
|
|
86
87
|
{ pullFutureContent: false, availableContentStatuses: ['published'] },
|
|
87
|
-
getFieldsForContentType(),
|
|
88
|
+
getFieldsForContentType('leaving'),
|
|
88
89
|
sortOrder
|
|
89
90
|
)
|
|
90
91
|
return fetchSanity(query, true)
|
|
@@ -99,11 +100,12 @@ export async function fetchLeaving(brand, { pageNumber = 1, contentPerPage = 20
|
|
|
99
100
|
* @returns {Promise<Object|null>}
|
|
100
101
|
*/
|
|
101
102
|
export async function fetchReturning(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
102
|
-
const
|
|
103
|
-
const
|
|
103
|
+
const today = new Date()
|
|
104
|
+
const isoDateOnly = today.toISOString().split('T')[0]
|
|
105
|
+
const filterString = `brand == '${brand}' && quarter_published >= '${isoDateOnly}'`
|
|
104
106
|
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
105
107
|
const sortOrder = {
|
|
106
|
-
sortOrder: 'published_on desc, id desc',
|
|
108
|
+
sortOrder: 'quarter_published asc, published_on desc, id desc',
|
|
107
109
|
start: startEndOrder['start'],
|
|
108
110
|
end: startEndOrder['end'],
|
|
109
111
|
}
|
|
@@ -1344,8 +1344,8 @@ export function findIncompleteLesson(progressOnItems, currentContentId, contentT
|
|
|
1344
1344
|
export async function pinProgressRow(brand, id, progressType) {
|
|
1345
1345
|
const url = `/api/user-management-system/v1/progress/pin?brand=${brand}&id=${id}&progressType=${progressType}`;
|
|
1346
1346
|
const response = await fetchHandler(url, 'PUT', null)
|
|
1347
|
-
if (response && !response.error) {
|
|
1348
|
-
await
|
|
1347
|
+
if (response && !response.error && response['action'] === 'update_user_pin') {
|
|
1348
|
+
await updateUserPinnedProgressRow(brand, {
|
|
1349
1349
|
id,
|
|
1350
1350
|
progressType,
|
|
1351
1351
|
pinnedAt: new Date().toISOString(),
|
|
@@ -1357,23 +1357,25 @@ export async function pinProgressRow(brand, id, progressType) {
|
|
|
1357
1357
|
* Unpins the current pinned progress row for a user, scoped by brand.
|
|
1358
1358
|
*
|
|
1359
1359
|
* @param {string} brand - The brand context for the unpin action.
|
|
1360
|
+
* @param {string} id - The content or playlist id to unpin.
|
|
1360
1361
|
* @returns {Promise<Object>} - A promise resolving to the response from the unpin API.
|
|
1361
1362
|
*
|
|
1362
1363
|
* @example
|
|
1363
|
-
* unpinProgressRow('drumeo')
|
|
1364
|
+
* unpinProgressRow('drumeo', 123456)
|
|
1364
1365
|
* .then(response => console.log(response))
|
|
1365
1366
|
* .catch(error => console.error(error));
|
|
1366
1367
|
*/
|
|
1367
|
-
export async function unpinProgressRow(brand) {
|
|
1368
|
-
|
|
1368
|
+
export async function unpinProgressRow(brand, id) {
|
|
1369
|
+
if (!(brand && id)) throw new Error(`undefined parameter brand: ${brand} or id: ${id}`)
|
|
1370
|
+
const url = `/api/user-management-system/v1/progress/unpin?brand=${brand}&id=${id}`
|
|
1369
1371
|
const response = await fetchHandler(url, 'PUT', null)
|
|
1370
|
-
if (response && !response.error) {
|
|
1371
|
-
await
|
|
1372
|
+
if (response && !response.error && response['action'] === 'clear_user_pin') {
|
|
1373
|
+
await updateUserPinnedProgressRow(brand, null)
|
|
1372
1374
|
}
|
|
1373
1375
|
return response
|
|
1374
1376
|
}
|
|
1375
1377
|
|
|
1376
|
-
async function
|
|
1378
|
+
async function updateUserPinnedProgressRow(brand, pinnedData) {
|
|
1377
1379
|
const userRaw = await globalConfig.localStorage.getItem('user');
|
|
1378
1380
|
const user = userRaw ? JSON.parse(userRaw) : {};
|
|
1379
1381
|
user.brand_pinned_progress = user.brand_pinned_progress || {}
|