sr-npm 1.7.493 → 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 +11 -2
- 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 || '',
|