sr-npm 1.7.8 → 1.7.10

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/consts.js CHANGED
@@ -1,4 +1,4 @@
1
- const {saveDataJobsToCMS,saveJobsDescriptionsToCMS,aggregateJobsByFieldToCMS,referenceJobsToField} = require('./data');
1
+ const {saveDataJobsToCMS,saveJobsDescriptionsAndLocationToCMS,aggregateJobsByFieldToCMS,referenceJobsToField} = require('./data');
2
2
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
3
3
  const TASKS_NAMES = {
4
4
  SYNC_JOBS: 'syncJobsFromSRAPIToCMS',
@@ -62,7 +62,7 @@ const TASKS = {
62
62
  [TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_TO_CMS]: {
63
63
  name: TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_TO_CMS,
64
64
  getIdentifier:()=> "SHOULD_NEVER_SKIP",
65
- process:saveJobsDescriptionsToCMS,
65
+ process:saveJobsDescriptionsAndLocationToCMS,
66
66
  shouldSkipCheck:()=>false,
67
67
  estimatedDurationSec:20
68
68
  },
package/backend/data.js CHANGED
@@ -55,9 +55,9 @@ async function saveDataJobsToCMS() {
55
55
 
56
56
  }
57
57
 
58
- async function saveJobsDescriptionsToCMS() {
58
+ async function saveJobsDescriptionsAndLocationToCMS() {
59
59
 
60
- console.log('🚀 Starting job descriptions update process for ALL jobs using pagination...');
60
+ console.log('🚀 Starting job descriptions update process for ALL jobs using pagination...');
61
61
 
62
62
  try {
63
63
  let jobsWithNoDescriptions = await getJobsWithNoDescriptions();
@@ -94,8 +94,11 @@ async function saveJobsDescriptionsToCMS() {
94
94
  try {
95
95
  // console.log(` Fetching description for: ${job.title} (${job._id})`);
96
96
  const jobDetails = await fetchJobDescription(job._id);
97
+ const jobLocation = fetchJobLocation(jobDetails)
98
+
97
99
  const updatedJob = {
98
100
  ...job,
101
+ locationAddress: jobLocation,
99
102
  jobDescription: jobDetails.jobAd.sections
100
103
  };
101
104
  await wixData.update("Jobs", updatedJob);
@@ -287,9 +290,33 @@ async function referenceJobsToField({
287
290
  return { success: true, updated: jobsToUpdate.length };
288
291
  }
289
292
 
293
+ function fetchJobLocation(jobDetails) {
294
+ console.log("jobDetails.location is ", jobDetails.location);
295
+ const isZeroLocation = jobDetails.location.latitude === "0.0000" && jobDetails.location.longitude === "0.0000";
296
+ const jobLocation = {
297
+ location: isZeroLocation ? {} : {
298
+ latitude: parseFloat(jobDetails.location.latitude),
299
+ longitude: parseFloat(jobDetails.location.longitude)
300
+ },
301
+ city: jobDetails.location.city,
302
+ country: jobDetails.location.country,
303
+ formatted: [
304
+ jobDetails.location.city,
305
+ jobDetails.location.region,
306
+ jobDetails.location.regionCode,
307
+ jobDetails.location.country
308
+ ].filter(Boolean).join(', '),
309
+ streetAddress: {},
310
+ subdivision: "",
311
+ postalCode: ""
312
+ };
313
+ return jobLocation;
314
+
315
+ }
316
+
290
317
  module.exports = {
291
318
  saveDataJobsToCMS,
292
- saveJobsDescriptionsToCMS,
319
+ saveJobsDescriptionsAndLocationToCMS,
293
320
  aggregateJobsByFieldToCMS,
294
321
  referenceJobsToField,
295
322
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {