sr-npm 1.7.116 → 1.7.118

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 {saveJobsDataToCMS,saveJobsDescriptionsAndLocationApplyUrlToCMS,aggregateJobsByFieldToCMS,referenceJobsToField,createApiKeyCollectionAndFillIt,createCollections,aggregateJobs,referenceJobs} = require('./data');
1
+ const {saveJobsDataToCMS,saveJobsDescriptionsAndLocationApplyUrlToCMS,aggregateJobsByFieldToCMS,referenceJobsToField,createApiKeyCollectionAndFillIt} = require('./data');
2
2
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
3
3
  const { COLLECTIONS, COLLECTIONS_FIELDS, JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
4
4
 
@@ -8,9 +8,13 @@ const TASKS_NAMES = {
8
8
  SYNC_JOBS: 'syncJobsFromSRAPIToCMS',
9
9
  INSERT_JOBS_TO_CMS: 'insertJobsToCMS',
10
10
  INSERT_JOBS_DESCRIPTIONS_LOCATION_APPLY_URL_TO_CMS: 'insertJobsDescriptionsLocationApplyUrlToCMS',
11
- AGGREGATE_JOBS_BY_FIELD_TO_CMS: 'aggregateJobsByFieldToCMS',
12
- REFERENCE_JOBS: 'referenceJobs',
13
- CREATE_COLLECTIONS: 'createCollections',
11
+ FILL_JOBS_PER_CITY_COLLECTION: 'fillJobsPerCityCollection',
12
+ FILL_JOBS_PER_DEPARTMENT_COLLECTION: 'fillJobsPerDepartmentCollection',
13
+ REFERENCE_JOBS_TO_LOCATIONS: 'referenceJobsToLocations',
14
+ REFERENCE_JOBS_TO_DEPARTMENT: 'referenceJobsToDepartment',
15
+ CREATE_JOBS_COLLECTION: 'createJobsCollection',
16
+ CREATE_CITIES_COLLECTION: 'createCitiesCollection',
17
+ CREATE_AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION: 'createAmountOfJobsPerDepartmentCollection',
14
18
  CREATE_API_KEY_COLLECTION_AND_FILL_IT: 'createApiKeyCollectionAndFillIt',
15
19
  }
16
20
 
@@ -19,21 +23,39 @@ const TASKS = {
19
23
  [TASKS_NAMES.SYNC_JOBS]: {
20
24
  name: TASKS_NAMES.SYNC_JOBS,
21
25
  childTasks: [
22
- { name: TASKS_NAMES.CREATE_COLLECTIONS},
26
+ { name: TASKS_NAMES.CREATE_JOBS_COLLECTION },
27
+ { name: TASKS_NAMES.CREATE_CITIES_COLLECTION },
28
+ {name: TASKS_NAMES.CREATE_AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION},
23
29
  { name: TASKS_NAMES.INSERT_JOBS_TO_CMS },
24
30
  { name: TASKS_NAMES.INSERT_JOBS_DESCRIPTIONS_LOCATION_APPLY_URL_TO_CMS },
25
- { name: TASKS_NAMES.AGGREGATE_JOBS_BY_FIELD_TO_CMS },
26
- {name: TASKS_NAMES.REFERENCE_JOBS},
31
+ { name: TASKS_NAMES.FILL_JOBS_PER_CITY_COLLECTION },
32
+ { name: TASKS_NAMES.FILL_JOBS_PER_DEPARTMENT_COLLECTION },
33
+ { name: TASKS_NAMES.REFERENCE_JOBS_TO_LOCATIONS },
34
+ { name: TASKS_NAMES.REFERENCE_JOBS_TO_DEPARTMENT },
27
35
  ],
28
36
  scheduleChildrenSequentially: true,
29
- estimatedDurationSec: 60,
37
+ estimatedDurationSec: 30,
30
38
  },
31
- [TASKS_NAMES.CREATE_COLLECTIONS]: {
32
- name: TASKS_NAMES.CREATE_COLLECTIONS,
39
+ [TASKS_NAMES.CREATE_JOBS_COLLECTION]: {
40
+ name: TASKS_NAMES.CREATE_JOBS_COLLECTION,
33
41
  getIdentifier:()=> "SHOULD_NEVER_SKIP",
34
- process:createCollections,
42
+ process:()=>createCollectionIfMissing(COLLECTIONS.JOBS, COLLECTIONS_FIELDS.JOBS,{ insert: 'ADMIN', update: 'ADMIN', remove: 'ADMIN', read: 'ANYONE' }),
35
43
  shouldSkipCheck:()=>false,
36
- estimatedDurationSec:7
44
+ estimatedDurationSec:3
45
+ },
46
+ [TASKS_NAMES.CREATE_CITIES_COLLECTION]: {
47
+ name: TASKS_NAMES.CREATE_CITIES_COLLECTION,
48
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
49
+ process:()=>createCollectionIfMissing(COLLECTIONS.CITIES, COLLECTIONS_FIELDS.CITIES),
50
+ shouldSkipCheck:()=>false,
51
+ estimatedDurationSec:3
52
+ },
53
+ [TASKS_NAMES.CREATE_AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION]: {
54
+ name: TASKS_NAMES.CREATE_AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION,
55
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
56
+ process:()=>createCollectionIfMissing(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, COLLECTIONS_FIELDS.AMOUNT_OF_JOBS_PER_DEPARTMENT),
57
+ shouldSkipCheck:()=>false,
58
+ estimatedDurationSec:3
37
59
  },
38
60
  [TASKS_NAMES.INSERT_JOBS_TO_CMS]: {
39
61
  name: TASKS_NAMES.INSERT_JOBS_TO_CMS,
@@ -49,20 +71,34 @@ const TASKS = {
49
71
  shouldSkipCheck:()=>false,
50
72
  estimatedDurationSec:20
51
73
  },
52
- [TASKS_NAMES.AGGREGATE_JOBS_BY_FIELD_TO_CMS]: {
53
- name: TASKS_NAMES.AGGREGATE_JOBS_BY_FIELD_TO_CMS,
54
- getIdentifier:()=> "SHOULD_NEVER_SKIP",
55
- process:aggregateJobs,
56
- shouldSkipCheck:()=>false,
57
- estimatedDurationSec:6
58
- },
59
- [TASKS_NAMES.REFERENCE_JOBS]: {
60
- name: TASKS_NAMES.REFERENCE_JOBS,
61
- getIdentifier:()=> "SHOULD_NEVER_SKIP",
62
- process:referenceJobs,
63
- shouldSkipCheck:()=>false,
64
- estimatedDurationSec:6
65
- },
74
+ [TASKS_NAMES.FILL_JOBS_PER_CITY_COLLECTION]: {
75
+ name: TASKS_NAMES.FILL_JOBS_PER_CITY_COLLECTION,
76
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
77
+ process:()=>aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.CITY_TEXT, collection: COLLECTIONS.CITIES }),
78
+ shouldSkipCheck:()=>false,
79
+ estimatedDurationSec:3
80
+ },
81
+ [TASKS_NAMES.FILL_JOBS_PER_DEPARTMENT_COLLECTION]: {
82
+ name: TASKS_NAMES.FILL_JOBS_PER_DEPARTMENT_COLLECTION,
83
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
84
+ process:()=>aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.DEPARTMENT, collection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT }),
85
+ shouldSkipCheck:()=>false,
86
+ estimatedDurationSec:3
87
+ },
88
+ [TASKS_NAMES.REFERENCE_JOBS_TO_LOCATIONS]: {
89
+ name: TASKS_NAMES.REFERENCE_JOBS_TO_LOCATIONS,
90
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
91
+ process:()=>referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.CITY, sourceCollection: COLLECTIONS.CITIES, jobField: JOBS_COLLECTION_FIELDS.CITY_TEXT }),
92
+ shouldSkipCheck:()=>false,
93
+ estimatedDurationSec:3
94
+ },
95
+ [TASKS_NAMES.REFERENCE_JOBS_TO_DEPARTMENT]: {
96
+ name: TASKS_NAMES.REFERENCE_JOBS_TO_DEPARTMENT,
97
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
98
+ process:()=>referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.DEPARTMENT_REF, sourceCollection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, jobField: JOBS_COLLECTION_FIELDS.DEPARTMENT }),
99
+ shouldSkipCheck:()=>false,
100
+ estimatedDurationSec:3
101
+ },
66
102
  [TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT]: {
67
103
  name: TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT,
68
104
  getIdentifier:()=> "SHOULD_NEVER_SKIP",
package/backend/data.js CHANGED
@@ -18,7 +18,7 @@ function validatePosition(position) {
18
18
  if (!position.department || !position.department.label) {
19
19
  throw new Error('Position department is required and must have a label');
20
20
  }
21
- if (!position.location || !position.location.city || typeof position.location.remote !== 'boolean') {
21
+ if (!position.location || !position.location.city || typeof position.location.remote !== 'boolean') {
22
22
  throw new Error('Position location is required and must have a city and remote');
23
23
  }
24
24
 
@@ -29,10 +29,12 @@ async function saveJobsDataToCMS() {
29
29
  // bulk insert to jobs collection without descriptions first
30
30
  const jobsData = positions.content.map(position => {
31
31
  validatePosition(position);
32
+ console.log("before: position.department.label", position.department.label);
33
+ console.log("after: position.department.label", position.department.label.replace('&', ' and '));
32
34
  const basicJob = {
33
35
  _id: position.id,
34
36
  title: position.title,
35
- department: position.department.label,
37
+ department: position.department.label.replace('&', ' and '),
36
38
  cityText: normalizeCityName(position.location.city),
37
39
  location: position.location,
38
40
  country: position.location.country,
@@ -43,6 +45,7 @@ async function saveJobsDataToCMS() {
43
45
  };
44
46
  return basicJob;
45
47
  });
48
+ console.log("jobsData@@@@@@@", jobsData);
46
49
 
47
50
  const chunkSize = 1000;
48
51
  let totalSaved = 0;
@@ -130,10 +133,6 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
130
133
  console.log(
131
134
  ` API chunk ${chunkNumber} completed: ${chunkSuccesses} success, ${chunkFailures} failed`
132
135
  );
133
- if (chunkNumber * API_CHUNK_SIZE < jobsWithNoDescriptions.items.length) {
134
- console.log(' Waiting 2 seconds before next API chunk...');
135
- await delay(2000);
136
- }
137
136
  },
138
137
  });
139
138
 
@@ -158,6 +157,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
158
157
  }
159
158
  }
160
159
 
160
+
161
161
  function iterateOverAllJobs(results, field) {
162
162
  const jobsPerField = {};
163
163
  const cityLocations = {};
@@ -299,36 +299,8 @@ async function createApiKeyCollectionAndFillIt() {
299
299
  console.log("Smart token inserted into the ApiKey collection");
300
300
  }
301
301
 
302
- async function createCollections() {
303
- console.log("Creating collections");
304
- Promise.all(
305
- [createCollectionIfMissing(COLLECTIONS.JOBS, JOBS_COLLECTION_FIELDS.JOBS,{ insert: 'ADMIN', update: 'ADMIN', remove: 'ADMIN', read: 'ANYONE' }),
306
- createCollectionIfMissing(COLLECTIONS.CITIES, COLLECTIONS_FIELDS.CITIES),
307
- createCollectionIfMissing(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, COLLECTIONS_FIELDS.AMOUNT_OF_JOBS_PER_DEPARTMENT)
308
- ]);
309
- console.log("finished creating Collections");
310
- }
311
-
312
- async function aggregateJobs() {
313
- console.log("Aggregating jobs");
314
- Promise.all([
315
- aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.CITY_TEXT, collection: COLLECTIONS.CITIES }),
316
- aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.DEPARTMENT, collection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT })
317
- ]);
318
- console.log("finished aggregating jobs");
319
- }
320
-
321
- async function referenceJobs() {
322
- console.log("Reference jobs");
323
- await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.DEPARTMENT_REF, sourceCollection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, jobField: JOBS_COLLECTION_FIELDS.DEPARTMENT })
324
- await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.CITY, sourceCollection: COLLECTIONS.CITIES, jobField: JOBS_COLLECTION_FIELDS.CITY_TEXT }),
325
- console.log("finished referencing jobs");
326
- }
327
302
 
328
303
  module.exports = {
329
- referenceJobs,
330
- aggregateJobs,
331
- createCollections,
332
304
  saveJobsDataToCMS,
333
305
  saveJobsDescriptionsAndLocationApplyUrlToCMS,
334
306
  aggregateJobsByFieldToCMS,
@@ -3,7 +3,7 @@ const { items: wixData } = require('@wix/data');
3
3
  const { COLLECTIONS } = require('./collectionConsts');
4
4
  async function makeSmartRecruitersRequest(path,token) {
5
5
  const baseUrl = 'https://api.smartrecruiters.com'; // PROD
6
- //const baseUrl = 'https://bayank2.wixstudio.com/my-site-3//_functions'; // TEST
6
+ // const baseUrl = 'https://bayank2.wixstudio.com/my-site-3//_functions'; // TEST
7
7
  const fullUrl = `${baseUrl}${path}`;
8
8
 
9
9
  //console.log(`Making request to: ${fullUrl}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.116",
3
+ "version": "1.7.118",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/pages/homePage.js CHANGED
@@ -31,8 +31,7 @@ async function homePageOnReady(_$w,thisObject) {
31
31
  longitude: location.longitude
32
32
  },
33
33
  address: item.locationAddress.formatted,
34
- //description: `<a href=${linkUrl} target="_parent" rel="noopener noreferrer" style="color:#000000;text-decoration:underline;font-weight:bold;">View ${item.count} Open Positions</a>`
35
- description: 'bayan'
34
+ description: `<a href=${linkUrl} target="_parent" rel="noopener noreferrer" style="color:#000000;text-decoration:underline;font-weight:bold;">View ${item.count} Open Positions</a>`
36
35
  };
37
36
  });
38
37
  //@ts-ignore