sr-npm 1.7.269 → 1.7.271
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 +1 -1
- package/backend/data.js +15 -4
- package/backend/fetchPositionsFromSRAPI.js +2 -6
- package/package.json +1 -1
package/backend/consts.js
CHANGED
|
@@ -67,7 +67,7 @@ const TASKS = {
|
|
|
67
67
|
[TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT]: {
|
|
68
68
|
name: TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT,
|
|
69
69
|
getIdentifier:()=> "SHOULD_NEVER_SKIP",
|
|
70
|
-
process:
|
|
70
|
+
process:createApiKeyCollectionAndFillIt,
|
|
71
71
|
shouldSkipCheck:()=>false,
|
|
72
72
|
estimatedDurationSec:3
|
|
73
73
|
},
|
package/backend/data.js
CHANGED
|
@@ -295,11 +295,21 @@ async function createApiKeyCollectionAndFillIt() {
|
|
|
295
295
|
const token = await getSmartToken();
|
|
296
296
|
console.log("token is : ", token);
|
|
297
297
|
console.log("Inserting the smart token into the ApiKey collection");
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
try {
|
|
299
|
+
await wixData.insert(COLLECTIONS.API_KEY, {
|
|
300
|
+
token: token.value
|
|
301
|
+
});
|
|
302
|
+
console.log("Smart token inserted into the ApiKey collection");
|
|
303
|
+
} catch (error) {
|
|
304
|
+
if (error.message.includes("WDE0074: An item with _id [SINGLE_ITEM_ID] already exists")) {
|
|
305
|
+
console.log("Smart token already exists in the ApiKey collection");
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
301
311
|
|
|
302
|
-
|
|
312
|
+
|
|
303
313
|
}
|
|
304
314
|
|
|
305
315
|
async function createCollections() {
|
|
@@ -330,6 +340,7 @@ async function referenceJobs() {
|
|
|
330
340
|
|
|
331
341
|
async function syncJobsFast() {
|
|
332
342
|
console.log("Syncing jobs fast");
|
|
343
|
+
await createApiKeyCollectionAndFillIt();
|
|
333
344
|
await createCollections();
|
|
334
345
|
await clearCollections();
|
|
335
346
|
console.log("saving jobs data to CMS");
|
|
@@ -3,11 +3,9 @@ const { items: wixData } = require('@wix/data');
|
|
|
3
3
|
const { COLLECTIONS } = require('./collectionConsts');
|
|
4
4
|
const secretsData = require('./secretsData');
|
|
5
5
|
async function makeSmartRecruitersRequest(path,token) {
|
|
6
|
-
const baseUrl = 'https://api.smartrecruiters.com';
|
|
7
|
-
// const baseUrl = 'https://bayank2.wixstudio.com/my-site-3//_functions'; // TEST
|
|
6
|
+
const baseUrl = 'https://api.smartrecruiters.com';
|
|
8
7
|
const fullUrl = `${baseUrl}${path}`;
|
|
9
8
|
|
|
10
|
-
//console.log(`Making request to: ${fullUrl}`);
|
|
11
9
|
try {
|
|
12
10
|
const response = await fetch(fullUrl, {
|
|
13
11
|
method: 'GET',
|
|
@@ -63,8 +61,6 @@ async function fetchPositionsFromSRAPI() {
|
|
|
63
61
|
console.log(`Total positions available: ${totalFound}`);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
// Get the nextPageId for the next iteration
|
|
67
|
-
// nextPageId = response.nextPageId && response.nextPageId !== '' ? response.nextPageId : null;
|
|
68
64
|
offset+=100;
|
|
69
65
|
|
|
70
66
|
} catch (error) {
|
|
@@ -109,7 +105,7 @@ async function fetchJobDescription(jobId) {
|
|
|
109
105
|
async function getSmartTokenFromCMS() {
|
|
110
106
|
const result = await wixData.query(COLLECTIONS.API_KEY).limit(1).find();
|
|
111
107
|
if (result.items.length > 0) {
|
|
112
|
-
return result.items[0].token;
|
|
108
|
+
return result.items[0].token;
|
|
113
109
|
} else {
|
|
114
110
|
throw new Error('[getSmartTokenFromCMS], No token found');
|
|
115
111
|
}
|