sr-npm 1.7.208 → 1.7.210
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 +20 -19
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -300,7 +300,7 @@ async function createApiKeyCollectionAndFillIt() {
|
|
|
300
300
|
|
|
301
301
|
async function createCollections() {
|
|
302
302
|
console.log("Creating collections");
|
|
303
|
-
Promise.all(
|
|
303
|
+
await Promise.all(
|
|
304
304
|
[createCollectionIfMissing(COLLECTIONS.JOBS, JOBS_COLLECTION_FIELDS.JOBS,{ insert: 'ADMIN', update: 'ADMIN', remove: 'ADMIN', read: 'ANYONE' }),
|
|
305
305
|
createCollectionIfMissing(COLLECTIONS.CITIES, COLLECTIONS_FIELDS.CITIES),
|
|
306
306
|
createCollectionIfMissing(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, COLLECTIONS_FIELDS.AMOUNT_OF_JOBS_PER_DEPARTMENT)
|
|
@@ -309,24 +309,20 @@ async function createCollections() {
|
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
async function aggregateJobs() {
|
|
312
|
-
console.log("truncating cities collection");
|
|
313
|
-
//await wixData.truncate(COLLECTIONS.CITIES);
|
|
314
|
-
console.log("truncating amount of jobs per department collection");
|
|
315
|
-
//await wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT);
|
|
316
312
|
console.log("Aggregating jobs");
|
|
317
|
-
await
|
|
318
|
-
|
|
313
|
+
await Promise.all([
|
|
314
|
+
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
|
+
]);
|
|
319
317
|
console.log("finished aggregating jobs");
|
|
320
318
|
}
|
|
321
319
|
|
|
322
320
|
async function referenceJobs() {
|
|
323
|
-
console.log("truncating cities collection");
|
|
324
|
-
//await wixData.truncate(COLLECTIONS.CITIES);
|
|
325
|
-
console.log("truncating amount of jobs per department collection");
|
|
326
|
-
//await wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT);
|
|
327
321
|
console.log("Reference jobs");
|
|
328
|
-
await
|
|
329
|
-
|
|
322
|
+
await Promise.all([
|
|
323
|
+
referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.DEPARTMENT_REF, sourceCollection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, jobField: JOBS_COLLECTION_FIELDS.DEPARTMENT }),
|
|
324
|
+
referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.CITY, sourceCollection: COLLECTIONS.CITIES, jobField: JOBS_COLLECTION_FIELDS.CITY_TEXT }),
|
|
325
|
+
]);
|
|
330
326
|
console.log("finished referencing jobs");
|
|
331
327
|
}
|
|
332
328
|
|
|
@@ -335,12 +331,7 @@ async function syncJobsFast() {
|
|
|
335
331
|
console.log("Creating collections");
|
|
336
332
|
await createCollections();
|
|
337
333
|
console.log("created collections successfully");
|
|
338
|
-
|
|
339
|
-
await wixData.truncate(COLLECTIONS.CITIES);
|
|
340
|
-
console.log("truncating amount of jobs per department collection");
|
|
341
|
-
await wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT);
|
|
342
|
-
console.log("truncating jobs collection");
|
|
343
|
-
await wixData.truncate(COLLECTIONS.JOBS);
|
|
334
|
+
await clearCollections();
|
|
344
335
|
console.log("saving jobs data to CMS");
|
|
345
336
|
await saveJobsDataToCMS();
|
|
346
337
|
console.log("saved jobs data to CMS successfully");
|
|
@@ -356,6 +347,16 @@ async function syncJobsFast() {
|
|
|
356
347
|
console.log("syncing jobs fast finished successfully");
|
|
357
348
|
}
|
|
358
349
|
|
|
350
|
+
async function clearCollections() {
|
|
351
|
+
console.log("clearing cities collection");
|
|
352
|
+
await wixData.truncate(COLLECTIONS.CITIES);
|
|
353
|
+
console.log("clearing amount of jobs per department collection");
|
|
354
|
+
await wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT);
|
|
355
|
+
console.log("clearing jobs collection");
|
|
356
|
+
await wixData.truncate(COLLECTIONS.JOBS);
|
|
357
|
+
console.log("cleared collections successfully");
|
|
358
|
+
}
|
|
359
|
+
|
|
359
360
|
module.exports = {
|
|
360
361
|
syncJobsFast,
|
|
361
362
|
referenceJobs,
|