sr-npm 1.7.1324 → 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.
Files changed (2) hide show
  1. package/backend/data.js +26 -8
  2. 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,11 +164,12 @@ async function retrieveJobsData() {
164
164
  return basicJob;
165
165
  });
166
166
 
167
- if (siteconfig.customFields==="true") {
168
-
169
- await populateCustomFieldsCollection(customFieldsLabels,templateType);
170
- await populateCustomValuesCollection(customFieldsValues);
171
- }
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
+ // }
172
173
 
173
174
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
174
175
  jobsData.sort((a, b) => {
@@ -195,6 +196,8 @@ async function populateCustomFieldsCollection(customFields,templateType) {
195
196
  _id: ID,
196
197
  })
197
198
  }
199
+
200
+ console.log("fieldstoinsert: cusotmfields ", fieldstoinsert);
198
201
  await wixData.bulkSave(COLLECTIONS.CUSTOM_FIELDS, fieldstoinsert);
199
202
  }
200
203
  async function populateCustomValuesCollection(customFieldsValues) {
@@ -213,6 +216,7 @@ async function populateCustomValuesCollection(customFieldsValues) {
213
216
  })
214
217
  }
215
218
  }
219
+ console.log("valuesToinsert: customFieldsValues ", valuesToinsert);
216
220
  await wixData.bulkSave(COLLECTIONS.CUSTOM_VALUES, valuesToinsert);
217
221
  }
218
222
 
@@ -420,12 +424,18 @@ async function syncJobsFast() {
420
424
  console.log("retrieving jobs descriptions and location apply url from SR API");
421
425
 
422
426
  const status=await retrieveJobsDescriptionsAndLocationApplyUrlReferences(jobsData);
423
- throw new Error("test");
424
427
  if(status.success){
425
428
 
426
429
  await clearCollections();
427
430
  const updatedJobs=status.updatedJobs;
428
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
+ }
429
439
  await saveJobsToCMS(updatedJobs);
430
440
 
431
441
  if (siteconfig.customFields==="true") {
@@ -448,6 +458,14 @@ throw new Error("test");
448
458
  }
449
459
 
450
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
+ // }
451
469
  const chunkSize = 1000;
452
470
  let totalSaved = 0;
453
471
  const totalChunks = Math.ceil(updatedJobs.length / chunkSize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.1324",
3
+ "version": "1.7.1326",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {