sr-npm 1.7.168 → 1.7.170
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 +5 -3
- package/backend/utils.js +6 -3
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -315,9 +315,11 @@ async function createCollections() {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
async function aggregateJobs() {
|
|
318
|
-
console.log("Aggregating jobs
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
console.log("Aggregating jobs");
|
|
319
|
+
Promise.all([
|
|
320
|
+
aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.CITY_TEXT, collection: COLLECTIONS.CITIES }),
|
|
321
|
+
aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.DEPARTMENT, collection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT })
|
|
322
|
+
]);
|
|
321
323
|
console.log("finished aggregating jobs");
|
|
322
324
|
}
|
|
323
325
|
|
package/backend/utils.js
CHANGED
|
@@ -12,9 +12,12 @@ async function delay(ms) {
|
|
|
12
12
|
function countJobsPerGivenField(jobs, field,jobsPerField) {
|
|
13
13
|
for (const job of jobs) {
|
|
14
14
|
if (!job[field]) {
|
|
15
|
-
throw new Error(`Job ${job._id} has no ${field} field`);
|
|
15
|
+
//throw new Error(`Job ${job._id} has no ${field} field`);
|
|
16
|
+
//skip for now
|
|
17
|
+
}
|
|
18
|
+
else{
|
|
19
|
+
jobsPerField[job[field]] = (jobsPerField[job[field]] || 0) + 1;
|
|
16
20
|
}
|
|
17
|
-
jobsPerField[job[field]] = (jobsPerField[job[field]] || 0) + 1;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -35,7 +38,7 @@ function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddre
|
|
|
35
38
|
value = normalizeCityName(value);
|
|
36
39
|
return {
|
|
37
40
|
title: value,
|
|
38
|
-
_id: value.replace(/\s+/g, ''),
|
|
41
|
+
_id: value.replace(/\s+/g, '').replace(/&/g, 'and'),
|
|
39
42
|
count: amount,
|
|
40
43
|
locationAddress: locAddress,
|
|
41
44
|
country: loc.country,
|