sr-npm 1.7.1325 → 1.7.1326
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 +23 -8
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -16,6 +16,8 @@ const { chunkedBulkOperation,
|
|
|
16
16
|
let customValuesToJobs = {}
|
|
17
17
|
let locationToJobs = {}
|
|
18
18
|
let siteconfig;
|
|
19
|
+
let customFieldsLabels = {}
|
|
20
|
+
let customFieldsValues = {}
|
|
19
21
|
const EXCLUDED_CUSTOM_FIELDS = new Set(["Department","Country"]);
|
|
20
22
|
|
|
21
23
|
function getBrand(customField) {
|
|
@@ -117,8 +119,6 @@ function getCustomFieldsAndValuesFromPosition(position, customFieldsLabels, cust
|
|
|
117
119
|
async function retrieveJobsData() {
|
|
118
120
|
const positions = await fetchPositionsFromSRAPI();
|
|
119
121
|
const sourcePositions = await filterBasedOnBrand(positions);
|
|
120
|
-
const customFieldsLabels = {}
|
|
121
|
-
const customFieldsValues = {}
|
|
122
122
|
|
|
123
123
|
const { templateType } = await getApiKeys();
|
|
124
124
|
if(siteconfig===undefined) {
|
|
@@ -164,12 +164,12 @@ async function retrieveJobsData() {
|
|
|
164
164
|
return basicJob;
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
if (siteconfig.customFields==="true") {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
167
|
+
// if (siteconfig.customFields==="true") {
|
|
168
|
+
// console.log("populating custom fields and values collections");
|
|
169
|
+
// await populateCustomFieldsCollection(customFieldsLabels,templateType);
|
|
170
|
+
// await populateCustomValuesCollection(customFieldsValues);
|
|
171
|
+
// console.log("populated custom fields and values collections successfully");
|
|
172
|
+
// }
|
|
173
173
|
|
|
174
174
|
// Sort jobs by title (ascending, case-insensitive, numeric-aware)
|
|
175
175
|
jobsData.sort((a, b) => {
|
|
@@ -429,6 +429,13 @@ async function syncJobsFast() {
|
|
|
429
429
|
await clearCollections();
|
|
430
430
|
const updatedJobs=status.updatedJobs;
|
|
431
431
|
console.log("saving jobs to CMS");
|
|
432
|
+
if (siteconfig.customFields==="true") {
|
|
433
|
+
const { templateType } = await getApiKeys();
|
|
434
|
+
console.log("populating custom fields and values collections");
|
|
435
|
+
await populateCustomFieldsCollection(customFieldsLabels,templateType);
|
|
436
|
+
await populateCustomValuesCollection(customFieldsValues);
|
|
437
|
+
console.log("populated custom fields and values collections successfully");
|
|
438
|
+
}
|
|
432
439
|
await saveJobsToCMS(updatedJobs);
|
|
433
440
|
|
|
434
441
|
if (siteconfig.customFields==="true") {
|
|
@@ -451,6 +458,14 @@ async function syncJobsFast() {
|
|
|
451
458
|
}
|
|
452
459
|
|
|
453
460
|
async function saveJobsToCMS(updatedJobs) {
|
|
461
|
+
// if (siteconfig.customFields==="true") {
|
|
462
|
+
// console.log("populating custom fields and values collections");
|
|
463
|
+
// const { templateType } = await getApiKeys();
|
|
464
|
+
|
|
465
|
+
// await populateCustomFieldsCollection(customFieldsLabels,templateType);
|
|
466
|
+
// await populateCustomValuesCollection(customFieldsValues);
|
|
467
|
+
// console.log("populated custom fields and values collections successfully");
|
|
468
|
+
// }
|
|
454
469
|
const chunkSize = 1000;
|
|
455
470
|
let totalSaved = 0;
|
|
456
471
|
const totalChunks = Math.ceil(updatedJobs.length / chunkSize);
|