sr-npm 1.7.638 → 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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.638",
3
+ "version": "1.7.639",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,8 +1,7 @@
1
1
  const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
2
2
  const { items: wixData } = require('@wix/data');
3
3
  const {CAREERS_MULTI_BOXES_PAGE_CONSTS} = require('../backend/careersMultiBoxesPageIds');
4
- const { auth } = require('@wix/essentials');
5
- const getAllRecordsElevated = auth.elevate(wixData.query);
4
+
6
5
  let valuesByFieldIdGlobal = null;
7
6
  let dontUpdateThisCheckBox;
8
7
  const selectedByField = new Map(); // fieldId -> array of selected value IDs
@@ -19,6 +18,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
19
18
  }
20
19
  if(Object.keys(valueToJobs).length === 0){
21
20
  allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
21
+
22
22
  for (const value of allvaluesobjects) {
23
23
  valueToJobs[value._id]= value.jobIds;
24
24
  }
@@ -82,7 +82,8 @@ async function loadJobs(_$w) {
82
82
  async function loadFilters(_$w) {
83
83
  try {
84
84
  // 1) Load all categories (fields)
85
- const fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
85
+ let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
86
+ fields.push({_id:"Location",title:"Location"});
86
87
  console.log("fields: ",fields)
87
88
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).data = fields;
88
89
  const cities=await getAllRecords(COLLECTIONS.CITIES);
@@ -156,15 +157,14 @@ async function loadJobs(_$w) {
156
157
  console.error('Failed to load filters:', err);
157
158
  }
158
159
  }
159
-
160
+
160
161
 
161
162
  async function getAllRecords(collectionId) {
162
- //let q = wixData.query(collectionId);
163
- let q=getAllRecordsElevated(collectionId)
163
+ let q = wixData.query(collectionId);
164
164
 
165
165
 
166
166
  const items = [];
167
- let res = await q.limit(1000).find()
167
+ let res = await q.limit(1000).find();
168
168
  items.push(...res.items);
169
169
 
170
170
  while (res.hasNext()) {