sr-npm 1.7.1318 → 1.7.1320

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 +56 -47
  2. package/package.json +1 -1
package/backend/data.js CHANGED
@@ -165,8 +165,11 @@ async function saveJobsDataToCMS() {
165
165
  });
166
166
 
167
167
  if (siteconfig.customFields==="true") {
168
+ console.log("populating custom fields collection");
168
169
  await populateCustomFieldsCollection(customFieldsLabels,templateType);
170
+ console.log("populating custom values collection");
169
171
  await populateCustomValuesCollection(customFieldsValues);
172
+ console.log("populated custom fields and values collections successfully");
170
173
  }
171
174
 
172
175
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
@@ -282,7 +285,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS(jobsWithNo
282
285
  const richContentConverterToken = await getTokenFromCMS(TOKEN_NAME.RICH_CONTENT_CONVERTER_TOKEN);
283
286
 
284
287
  console.log("before promise all")
285
- jobsWithNoDescriptions=await Promise.all(jobsWithNoDescriptions.map( async job => {
288
+ const jobsWithDescriptions=await Promise.all(jobsWithNoDescriptions.map( async job => {
286
289
  const jobDetails = await fetchJobDescription(job._id);
287
290
  const richContentDescription= await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken);
288
291
  const jobLocation = fetchJobLocation(jobDetails);
@@ -296,8 +299,8 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS(jobsWithNo
296
299
  };
297
300
  return updatedJob;
298
301
  }))
299
- console.log("jobsWithNoDescriptions: after map ",jobsWithNoDescriptions);
300
- return {success: true, updatedJobs: jobsWithNoDescriptions};
302
+ console.log("jobsWithDescriptions: after map ",jobsWithDescriptions);
303
+ return {success: true, updatedJobs: jobsWithDescriptions};
301
304
 
302
305
  // await chunkedBulkOperation({
303
306
  // items: jobsWithNoDescriptions.items,
@@ -527,7 +530,7 @@ async function syncJobsFast() {
527
530
  try{
528
531
  console.log("Syncing jobs fast");
529
532
  await createCollections();
530
- // await clearCollections();
533
+ await clearCollections();
531
534
  await fillSecretManagerMirror();
532
535
 
533
536
  console.log("saving jobs data to CMS");//change comment
@@ -539,49 +542,55 @@ async function syncJobsFast() {
539
542
  const status=await saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS(jobsData);
540
543
 
541
544
  console.log("status inside syncJobsFast: ",status);
542
- // if(status.success){
543
- // await clearCollections();
544
- // const updatedJobs=status.updatedJobs;
545
- // const chunkSize = 1000;
546
- // let totalSaved = 0;
547
- // const totalChunks = Math.ceil(updatedJobs.length / chunkSize);
548
-
549
- // console.log(
550
- // `Processing ${updatedJobs.length} jobs in ${totalChunks} chunks of max ${chunkSize} items each`
551
- // );
545
+ if(status.success){
546
+ await wixData.truncate(COLLECTIONS.JOBS)
547
+ //await clearCollections();
548
+ const updatedJobs=status.updatedJobs;
549
+ const chunkSize = 1000;
550
+ let totalSaved = 0;
551
+ const totalChunks = Math.ceil(updatedJobs.length / chunkSize);
552
+
553
+ console.log(
554
+ `Processing ${updatedJobs.length} jobs in ${totalChunks} chunks of max ${chunkSize} items each`
555
+ );
552
556
 
553
- // await chunkedBulkOperation({
554
- // items: updatedJobs,
555
- // chunkSize,
556
- // processChunk: async (chunk, chunkNumber) => {
557
- // console.log(`Saving chunk ${chunkNumber}/${totalChunks}: ${chunk.length} jobs`);
558
- // try {
559
- // const result = await wixData.bulkSave(COLLECTIONS.JOBS, chunk);
560
- // const saved = result.inserted + result.updated || chunk.length;
561
- // totalSaved += saved;
562
- // console.log(
563
- // `✓ Chunk ${chunkNumber} saved successfully. Inserted: ${result.inserted}, Updated: ${result.updated}`
564
- // );
565
- // } catch (error) {
566
- // console.error(`✗ Error saving chunk ${chunkNumber}:`, error);
567
- // throw error;
568
- // }
569
- // },
570
- // });
571
- // console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${updatedJobs.length}`);
572
- // if (siteconfig.customFields==="true") {
573
- // let customValues = await getAllCustomValues();
574
-
575
- // console.log("inserting jobs references to custom values collection");
576
- // console.log("customValues: ",customValues)
577
- // console.log("customValues.items: ",customValues.items)
578
-
579
- // for (const value of customValues.items) {
580
- // await insertJobsReference(value._id, value.valueId);
581
- // }
582
- // console.log("inserted jobs references to custom values collection successfully");
583
- // }
584
- // }
557
+ await chunkedBulkOperation({
558
+ items: updatedJobs,
559
+ chunkSize,
560
+ processChunk: async (chunk, chunkNumber) => {
561
+ console.log(`Saving chunk ${chunkNumber}/${totalChunks}: ${chunk.length} jobs`);
562
+ try {
563
+ const result = await wixData.bulkSave(COLLECTIONS.JOBS, chunk);
564
+ const saved = result.inserted + result.updated || chunk.length;
565
+ totalSaved += saved;
566
+ console.log(
567
+ `✓ Chunk ${chunkNumber} saved successfully. Inserted: ${result.inserted}, Updated: ${result.updated}`
568
+ );
569
+ } catch (error) {
570
+ console.error(`✗ Error saving chunk ${chunkNumber}:`, error);
571
+ throw error;
572
+ }
573
+ },
574
+ });
575
+ console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${updatedJobs.length}`);
576
+ if (siteconfig.customFields==="true") {
577
+ console.log("inserting jobs references to custom values collection");
578
+
579
+ //put this inside function
580
+ //------------------------------------------------------------------------------------------------
581
+ let customValues = await getAllCustomValues();
582
+
583
+ console.log("inserting jobs references to custom values collection");
584
+ console.log("customValues: ",customValues)
585
+ console.log("customValues.items: ",customValues.items)
586
+
587
+ for (const value of customValues.items) {
588
+ await insertJobsReference(value._id, value.valueId);
589
+ }
590
+ console.log("inserted jobs references to custom values collection successfully");
591
+ }
592
+ //------------------------------------------------------------------------------------------------
593
+ }
585
594
  console.log("saved jobs descriptions and location apply url to CMS successfully");//change comment
586
595
 
587
596
  await aggregateJobs();
@@ -606,7 +615,7 @@ async function clearCollections() {
606
615
  await Promise.all([
607
616
  wixData.truncate(COLLECTIONS.CITIES),
608
617
  wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT),
609
- wixData.truncate(COLLECTIONS.JOBS),
618
+ //wixData.truncate(COLLECTIONS.JOBS),
610
619
  wixData.truncate(COLLECTIONS.BRANDS),
611
620
  siteconfig.customFields==="true" ? wixData.truncate(COLLECTIONS.CUSTOM_VALUES) : null,
612
621
  siteconfig.customFields==="true" ? wixData.truncate(COLLECTIONS.CUSTOM_FIELDS) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.1318",
3
+ "version": "1.7.1320",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {