sr-npm 1.7.637 → 1.7.639
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 +10 -4
- package/backend/utils.js +2 -1
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +3 -1
package/backend/data.js
CHANGED
|
@@ -7,7 +7,7 @@ const { getAllPositions } = require('./queries');
|
|
|
7
7
|
const { retrieveSecretVal, getTokenFromCMS } = require('./secretsData');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
let jobToCustomValues = {}
|
|
10
|
+
//let jobToCustomValues = {}
|
|
11
11
|
let customValuesToJobs = {}
|
|
12
12
|
let siteconfig;
|
|
13
13
|
const EXCLUDED_CUSTOM_FIELDS = new Set(["Department"]);
|
|
@@ -62,12 +62,17 @@ function validateSingleDesiredBrand(desiredBrand) {
|
|
|
62
62
|
throw new Error("Desired brand must be a single brand");
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
function getLocation(position,basicJob) {
|
|
66
|
+
|
|
67
|
+
customValuesToJobs[basicJob.cityText] ? customValuesToJobs[basicJob.cityText].push(position.id) : customValuesToJobs[basicJob.cityText]=[position.id]
|
|
68
|
+
|
|
69
|
+
}
|
|
65
70
|
function getEmploymentType(position,customFieldsValues) {
|
|
66
71
|
if (!customFieldsValues["employmentType"]) {
|
|
67
72
|
customFieldsValues["employmentType"] = {};
|
|
68
73
|
}
|
|
69
74
|
customFieldsValues["employmentType"][position.typeOfEmployment.id] = position.typeOfEmployment.label;
|
|
70
|
-
jobToCustomValues[position.id] ? jobToCustomValues[position.id].push(position.typeOfEmployment.id) : jobToCustomValues[position.id]=[position.typeOfEmployment.id]
|
|
75
|
+
//jobToCustomValues[position.id] ? jobToCustomValues[position.id].push(position.typeOfEmployment.id) : jobToCustomValues[position.id]=[position.typeOfEmployment.id]
|
|
71
76
|
customValuesToJobs[position.typeOfEmployment.id] ? customValuesToJobs[position.typeOfEmployment.id].push(position.id) : customValuesToJobs[position.typeOfEmployment.id]=[position.id]
|
|
72
77
|
}
|
|
73
78
|
|
|
@@ -86,7 +91,7 @@ function getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,custom
|
|
|
86
91
|
}
|
|
87
92
|
customFieldsValues[fieldId][valueId] = valueLabel;
|
|
88
93
|
|
|
89
|
-
jobToCustomValues[position.id] ? jobToCustomValues[position.id].push(valueId) : jobToCustomValues[position.id]=[valueId]
|
|
94
|
+
//jobToCustomValues[position.id] ? jobToCustomValues[position.id].push(valueId) : jobToCustomValues[position.id]=[valueId]
|
|
90
95
|
customValuesToJobs[valueId] ? customValuesToJobs[valueId].push(position.id) : customValuesToJobs[valueId]=[position.id]
|
|
91
96
|
}
|
|
92
97
|
}
|
|
@@ -125,6 +130,7 @@ async function saveJobsDataToCMS() {
|
|
|
125
130
|
|
|
126
131
|
getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
|
|
127
132
|
getEmploymentType(position,customFieldsValues);
|
|
133
|
+
getLocation(position,basicJob);
|
|
128
134
|
return basicJob;
|
|
129
135
|
});
|
|
130
136
|
if(siteconfig===undefined) {
|
|
@@ -309,7 +315,7 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
|
|
|
309
315
|
console.log(`counting jobs per ${field}.`);
|
|
310
316
|
let results = await getAllPositions();
|
|
311
317
|
const { jobsPerField, cityLocations,citylocationAddress } = iterateOverAllJobs(results, field);
|
|
312
|
-
const toSave = prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddress);
|
|
318
|
+
const toSave = prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddress,customValuesToJobs);
|
|
313
319
|
if (toSave.length === 0) {
|
|
314
320
|
console.log('No jobs found.');
|
|
315
321
|
return { success: true, message: 'No jobs to save.' };
|
package/backend/utils.js
CHANGED
|
@@ -30,7 +30,7 @@ function fillCityLocationAndLocationAddress(jobs, cityLocations,citylocationAddr
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddress) {
|
|
33
|
+
function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddress,customValuesToJobs=null) {
|
|
34
34
|
if (field === 'cityText') {
|
|
35
35
|
return Object.entries(jobsPerField).map(([value, amount]) => {
|
|
36
36
|
const loc = cityLocations[value] || {};
|
|
@@ -43,6 +43,7 @@ function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddre
|
|
|
43
43
|
locationAddress: locAddress,
|
|
44
44
|
country: loc.country,
|
|
45
45
|
city: loc.city,
|
|
46
|
+
jobIds: customValuesToJobs[value],
|
|
46
47
|
};
|
|
47
48
|
});
|
|
48
49
|
} else {
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
18
18
|
}
|
|
19
19
|
if(Object.keys(valueToJobs).length === 0){
|
|
20
20
|
allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
21
|
+
|
|
21
22
|
for (const value of allvaluesobjects) {
|
|
22
23
|
valueToJobs[value._id]= value.jobIds;
|
|
23
24
|
}
|
|
@@ -81,7 +82,8 @@ async function loadJobs(_$w) {
|
|
|
81
82
|
async function loadFilters(_$w) {
|
|
82
83
|
try {
|
|
83
84
|
// 1) Load all categories (fields)
|
|
84
|
-
|
|
85
|
+
let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
|
|
86
|
+
fields.push({_id:"Location",title:"Location"});
|
|
85
87
|
console.log("fields: ",fields)
|
|
86
88
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).data = fields;
|
|
87
89
|
const cities=await getAllRecords(COLLECTIONS.CITIES);
|