sr-npm 1.7.477 → 1.7.479
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 +3 -7
- package/backend/utils.js +4 -3
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -7,10 +7,7 @@ const { getAllPositions } = require('./queries');
|
|
|
7
7
|
const { getCompanyId, getSmartToken } = require('./secretsData');
|
|
8
8
|
|
|
9
9
|
function getBrand(customField) {
|
|
10
|
-
|
|
11
|
-
console.log("brand: ", brand);
|
|
12
|
-
console.log("normalizeString(brand): ", normalizeString(brand));
|
|
13
|
-
return brand ? normalizeString(brand) : '';
|
|
10
|
+
return customField.find(field => field.fieldLabel === 'Brands')?.valueLabel;
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
function validatePosition(position) {
|
|
@@ -37,7 +34,7 @@ async function saveJobsDataToCMS() {
|
|
|
37
34
|
_id: position.id,
|
|
38
35
|
title: position.name || '',
|
|
39
36
|
department: position.department?.label || 'Other',
|
|
40
|
-
cityText: normalizeString(position.location?.city)
|
|
37
|
+
cityText: normalizeString(position.location?.city),
|
|
41
38
|
location: position.location && Object.keys(position.location).length > 0
|
|
42
39
|
? position.location
|
|
43
40
|
: {
|
|
@@ -312,8 +309,7 @@ async function aggregateJobs() {
|
|
|
312
309
|
console.log("Aggregating jobs");
|
|
313
310
|
await Promise.all([
|
|
314
311
|
aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.DEPARTMENT, collection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT }),
|
|
315
|
-
aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.CITY_TEXT, collection: COLLECTIONS.CITIES })
|
|
316
|
-
aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.BRAND, collection: COLLECTIONS.BRANDS })
|
|
312
|
+
aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.CITY_TEXT, collection: COLLECTIONS.CITIES })
|
|
317
313
|
]);
|
|
318
314
|
console.log("finished aggregating jobs");
|
|
319
315
|
}
|
package/backend/utils.js
CHANGED
|
@@ -35,7 +35,7 @@ function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddre
|
|
|
35
35
|
return Object.entries(jobsPerField).map(([value, amount]) => {
|
|
36
36
|
const loc = cityLocations[value] || {};
|
|
37
37
|
const locAddress = citylocationAddress[value] || {};
|
|
38
|
-
value = normalizeString(value)
|
|
38
|
+
value = normalizeString(value);
|
|
39
39
|
return {
|
|
40
40
|
title: value,
|
|
41
41
|
_id: value.replace(/\s+/g, ''),
|
|
@@ -56,11 +56,12 @@ function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddre
|
|
|
56
56
|
|
|
57
57
|
function normalizeString(str) {
|
|
58
58
|
if (!str) return str;
|
|
59
|
-
// Remove accents/diacritics,
|
|
59
|
+
// Remove accents/diacritics, trim whitespace
|
|
60
60
|
return str
|
|
61
61
|
.normalize('NFD')
|
|
62
62
|
.replace(/\p{Diacritic}/gu, '')
|
|
63
|
-
.replace(/[^A-Za-z0-9
|
|
63
|
+
.replace(/[^A-Za-z0-9-]/g, '')
|
|
64
|
+
.trim();
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
|