sr-npm 1.7.492 → 1.7.494
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/backend/data.js +14 -4
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -4,7 +4,7 @@ const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend
|
|
|
4
4
|
const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
|
|
5
5
|
const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeString} = require('./utils');
|
|
6
6
|
const { getAllPositions } = require('./queries');
|
|
7
|
-
const { retrieveSecretVal } = require('./secretsData');
|
|
7
|
+
const { retrieveSecretVal, getTokenFromCMS } = require('./secretsData');
|
|
8
8
|
|
|
9
9
|
function getBrand(customField) {
|
|
10
10
|
return customField.find(field => field.fieldLabel === 'Brands')?.valueLabel;
|
|
@@ -28,8 +28,17 @@ function validatePosition(position) {
|
|
|
28
28
|
|
|
29
29
|
async function saveJobsDataToCMS() {
|
|
30
30
|
const positions = await fetchPositionsFromSRAPI();
|
|
31
|
+
const desiredBrand = await getTokenFromCMS(TOKEN_NAME.DESIRED_BRAND);
|
|
32
|
+
const sourcePositions = desiredBrand
|
|
33
|
+
? positions.content.filter(position => {
|
|
34
|
+
const brand = getBrand(position.customField);
|
|
35
|
+
if (!brand) return false;
|
|
36
|
+
return brand === desiredBrand;
|
|
37
|
+
})
|
|
38
|
+
: positions.content;
|
|
39
|
+
|
|
31
40
|
// bulk insert to jobs collection without descriptions first
|
|
32
|
-
const jobsData =
|
|
41
|
+
const jobsData = sourcePositions.map(position => {
|
|
33
42
|
const basicJob = {
|
|
34
43
|
_id: position.id,
|
|
35
44
|
title: position.name || '',
|
|
@@ -378,9 +387,10 @@ async function fillSecretManagerMirror() {
|
|
|
378
387
|
|
|
379
388
|
async function insertSecretValToCMS(tokenName) {
|
|
380
389
|
const token = await retrieveSecretVal(tokenName);
|
|
381
|
-
await wixData.
|
|
390
|
+
await wixData.save(COLLECTIONS.SECRET_MANAGER_MIRROR, {
|
|
382
391
|
tokenName: tokenName,
|
|
383
|
-
tokenValue: token.value
|
|
392
|
+
tokenValue: token.value,
|
|
393
|
+
_id: normalizeString(tokenName)
|
|
384
394
|
});
|
|
385
395
|
}
|
|
386
396
|
|