sr-npm 1.7.35 → 1.7.37

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.
@@ -9,29 +9,27 @@ const COLLECTIONS_FIELDS = {
9
9
  AMOUNT_OF_JOBS_PER_DEPARTMENT: [
10
10
  {key:'title', type: 'TEXT'},
11
11
  { key: 'count', type: 'NUMBER' },
12
+ { key: 'image', type: 'IMAGE' },
12
13
  ],
13
14
  CITIES: [
14
- {key:'title', type: 'TEXT'},
15
- { key: 'regionCode', type: 'TEXT' },
15
+ { key: 'title', type: 'TEXT' },
16
16
  { key: 'city', type: 'TEXT' },
17
- {key:'location', type: 'OBJECT'},
17
+ {key:'locationAddress', type: 'ADDRESS'},
18
18
  {key:'count', type: 'NUMBER'},
19
19
  {key:'country', type: 'TEXT'},
20
- {key:'remote', type: 'TEXT'},
21
- {key:'countryCode', type: 'TEXT'},
22
- {key:'manual', type: 'TEXT'},
23
- {key:'region', type: 'TEXT'},
24
- {key:'latitude', type: 'NUMBER'},
25
- {key:'longitude', type: 'NUMBER'},
26
20
  ],
27
21
  JOBS: [
28
22
  {key:'location', type: 'OBJECT'},
23
+ {key:'title', type: 'TEXT'},
24
+ {key:'locationAddress', type: 'ADDRESS'},
29
25
  {key:'postingStatus', type: 'TEXT'},
30
26
  {key:'country', type: 'TEXT'},
31
27
  {key:'department', type: 'TEXT'},
32
28
  {key:'language', type: 'TEXT'},
29
+ {key:'remote', type: 'BOOLEAN'},
33
30
  {key:'jobDescription', type: 'OBJECT'},
34
- {key:'cityText', type: 'TEXT'},
31
+ {key:'cityText', type: 'TEXT'},
32
+ {key:'applyLink', type: 'URL'},
35
33
  {key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'AmountOfJobsPerDepartment' } } },
36
34
  {key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'cities' } } },
37
35
  ],
package/backend/consts.js CHANGED
@@ -1,10 +1,10 @@
1
- const {saveDataJobsToCMS,saveJobsDescriptionsAndLocationToCMS,aggregateJobsByFieldToCMS,referenceJobsToField,createApiKeyCollectionAndFillIt} = require('./data');
1
+ const {saveDataJobsToCMS,saveJobsDescriptionsAndLocationApplyUrlToCMS,aggregateJobsByFieldToCMS,referenceJobsToField,createApiKeyCollectionAndFillIt} = require('./data');
2
2
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
3
3
  const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./collectionConsts');
4
4
  const TASKS_NAMES = {
5
5
  SYNC_JOBS: 'syncJobsFromSRAPIToCMS',
6
6
  INSERT_JOBS_TO_CMS: 'insertJobsToCMS',
7
- INSERT_JOBS_DESCRIPTIONS_TO_CMS: 'insertJobsDescriptionsToCMS',
7
+ INSERT_JOBS_DESCRIPTIONS_LOCATION_APPLY_URL_TO_CMS: 'insertJobsDescriptionsLocationApplyUrlToCMS',
8
8
  FILL_JOBS_PER_CITY_COLLECTION: 'fillJobsPerCityCollection',
9
9
  FILL_JOBS_PER_DEPARTMENT_COLLECTION: 'fillJobsPerDepartmentCollection',
10
10
  REFERENCE_JOBS_TO_LOCATIONS: 'referenceJobsToLocations',
@@ -24,7 +24,7 @@ const TASKS = {
24
24
  { name: TASKS_NAMES.CREATE_CITIES_COLLECTION },
25
25
  {name: TASKS_NAMES.CREATE_AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION},
26
26
  { name: TASKS_NAMES.INSERT_JOBS_TO_CMS },
27
- { name: TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_TO_CMS },
27
+ { name: TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_LOCATION_APPLY_URL_TO_CMS },
28
28
  { name: TASKS_NAMES.FILL_JOBS_PER_CITY_COLLECTION },
29
29
  { name: TASKS_NAMES.FILL_JOBS_PER_DEPARTMENT_COLLECTION },
30
30
  { name: TASKS_NAMES.REFERENCE_JOBS_TO_LOCATIONS },
@@ -36,7 +36,7 @@ const TASKS = {
36
36
  [TASKS_NAMES.CREATE_JOBS_COLLECTION]: {
37
37
  name: TASKS_NAMES.CREATE_JOBS_COLLECTION,
38
38
  getIdentifier:()=> "SHOULD_NEVER_SKIP",
39
- process:()=>createCollectionIfMissing(COLLECTIONS.JOBS, COLLECTIONS_FIELDS.JOBS),
39
+ process:()=>createCollectionIfMissing(COLLECTIONS.JOBS, COLLECTIONS_FIELDS.JOBS,{ insert: 'ADMIN', update: 'ADMIN', remove: 'ADMIN', read: 'ANYONE' }),
40
40
  shouldSkipCheck:()=>false,
41
41
  estimatedDurationSec:3
42
42
  },
@@ -61,10 +61,10 @@ const TASKS = {
61
61
  shouldSkipCheck:()=>false,
62
62
  estimatedDurationSec:20
63
63
  },
64
- [TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_TO_CMS]: {
65
- name: TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_TO_CMS,
64
+ [TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_LOCATION_APPLY_URL_TO_CMS]: {
65
+ name: TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_LOCATION_APPLY_URL_TO_CMS,
66
66
  getIdentifier:()=> "SHOULD_NEVER_SKIP",
67
- process:saveJobsDescriptionsAndLocationToCMS,
67
+ process:saveJobsDescriptionsAndLocationApplyUrlToCMS,
68
68
  shouldSkipCheck:()=>false,
69
69
  estimatedDurationSec:20
70
70
  },
package/backend/data.js CHANGED
@@ -59,7 +59,7 @@ async function saveDataJobsToCMS() {
59
59
 
60
60
  }
61
61
 
62
- async function saveJobsDescriptionsAndLocationToCMS() {
62
+ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
63
63
 
64
64
  console.log('🚀 Starting job descriptions update process for ALL jobs using pagination...');
65
65
 
@@ -99,11 +99,13 @@ async function saveJobsDescriptionsAndLocationToCMS() {
99
99
  // console.log(` Fetching description for: ${job.title} (${job._id})`);
100
100
  const jobDetails = await fetchJobDescription(job._id);
101
101
  const jobLocation = fetchJobLocation(jobDetails)
102
+ const applyLink = jobDetails.actions.applyOnWeb.url;
102
103
 
103
104
  const updatedJob = {
104
105
  ...job,
105
106
  locationAddress: jobLocation,
106
- jobDescription: jobDetails.jobAd.sections
107
+ jobDescription: jobDetails.jobAd.sections,
108
+ applyLink: applyLink
107
109
  };
108
110
  await wixData.update("Jobs", updatedJob);
109
111
  // console.log(` ✅ Updated description for: ${job.title}`);
@@ -170,6 +172,7 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
170
172
  let cityLocations = {};
171
173
  let query = wixData.query("Jobs").limit(1000);
172
174
  let results = await query.find();
175
+ const cityLocationAddress={}
173
176
  let page = 1;
174
177
  do {
175
178
  console.log(`Page ${page}: ${results.items.length} jobs.`);
@@ -179,7 +182,8 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
179
182
  throw new Error(`Job ${job._id} has no ${field} field`);
180
183
  }
181
184
  jobsPerField[job[field]] = (jobsPerField[job[field]] || 0) + 1;
182
- if (field === 'cityText' && !cityLocations[job[field]]) {
185
+ if (field === 'cityText' && !cityLocationAddress[job[field]] && !cityLocations[job[field]]) {
186
+ cityLocationAddress[job[field]] = job.locationAddress;
183
187
  cityLocations[job[field]] = job.location;
184
188
  }
185
189
  }
@@ -191,6 +195,7 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
191
195
  let toSave = [];
192
196
  if (field === 'cityText') {
193
197
  toSave = Object.entries(jobsPerField).map(([value, amount]) => {
198
+ const locAddress = cityLocationAddress[value] || {};
194
199
  const loc = cityLocations[value] || {};
195
200
  value = normalizeCityName(value);
196
201
 
@@ -198,16 +203,9 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
198
203
  title: value,
199
204
  _id: value.replace(/\s+/g, ''),
200
205
  count: amount,
201
- location: loc,
202
- countryCode: loc.countryCode,
206
+ locationAddress: locAddress,
203
207
  country: loc.country,
204
- region: loc.region,
205
208
  city: loc.city,
206
- manual: loc.manual.toString(),
207
- remote: loc.remote.toString(),
208
- regionCode: loc.regionCode,
209
- latitude: loc.latitude,
210
- longitude: loc.longitude
211
209
  };
212
210
  });
213
211
  }
@@ -236,7 +234,8 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
236
234
 
237
235
  async function getJobsWithNoDescriptions() {
238
236
 
239
- let jobswithoutdescriptionsQuery = await wixData.query("Jobs").limit(1000).isEmpty("jobDescription").find(); // with 900 as the limit, 429 error won't happen
237
+ // let jobswithoutdescriptionsQuery = await wixData.query("Jobs").limit(1000).isEmpty("jobDescription").find(); // with 900 as the limit, 429 error won't happen
238
+ let jobswithoutdescriptionsQuery = await wixData.query("Jobs").limit(1000).isEmpty("applyLink").find(); // with 900 as the limit, 429 error won't happen
240
239
  return jobswithoutdescriptionsQuery;
241
240
  }
242
241
 
@@ -318,7 +317,6 @@ function fetchJobLocation(jobDetails) {
318
317
  }
319
318
 
320
319
 
321
-
322
320
  function getSmartToken() {
323
321
  const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
324
322
  return elevatedGetSecretValue("x-smarttoken")
@@ -333,7 +331,7 @@ function getSmartToken() {
333
331
 
334
332
  async function createApiKeyCollectionAndFillIt() {
335
333
  console.log("Creating ApiKey collection and filling it with the smart token");
336
- await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY,null,'singleItem');
334
+ await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY);
337
335
  console.log("Getting the smart token");
338
336
  const token = await getSmartToken();
339
337
  console.log("token is : ", token);
@@ -348,7 +346,7 @@ async function createApiKeyCollectionAndFillIt() {
348
346
 
349
347
  module.exports = {
350
348
  saveDataJobsToCMS,
351
- saveJobsDescriptionsAndLocationToCMS,
349
+ saveJobsDescriptionsAndLocationApplyUrlToCMS,
352
350
  aggregateJobsByFieldToCMS,
353
351
  referenceJobsToField,
354
352
  createApiKeyCollectionAndFillIt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.35",
3
+ "version": "1.7.37",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "homepage": "https://github.com/psdevteamenterprise/sr-npm#readme",
19
19
  "dependencies": {
20
- "@hisense-staging/velo-npm": "1.7.251",
20
+ "@hisense-staging/velo-npm": "1.7.249",
21
21
  "@wix/data": "^1.0.211",
22
22
  "@wix/essentials": "^0.1.24",
23
23
  "@wix/secrets": "1.0.53"