sr-npm 1.7.19 → 1.7.21
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/data.js
CHANGED
|
@@ -3,7 +3,7 @@ const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositio
|
|
|
3
3
|
const { chunkedBulkOperation } = require('./utils');
|
|
4
4
|
const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
|
|
5
5
|
const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./collectionConsts');
|
|
6
|
-
const { secrets } = require("wix-secrets-backend
|
|
6
|
+
const { secrets } = require("wix-secrets-backend");
|
|
7
7
|
const { elevate } = require("wix-auth");
|
|
8
8
|
|
|
9
9
|
// Utility function to normalize city names
|
|
@@ -295,7 +295,6 @@ async function referenceJobsToField({
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
function fetchJobLocation(jobDetails) {
|
|
298
|
-
console.log("jobDetails.location is ", jobDetails.location);
|
|
299
298
|
const isZeroLocation = jobDetails.location.latitude === "0.0000" && jobDetails.location.longitude === "0.0000";
|
|
300
299
|
const jobLocation = {
|
|
301
300
|
location: isZeroLocation ? {} : {
|
|
@@ -346,6 +345,7 @@ async function createApiKeyCollectionAndFillIt() {
|
|
|
346
345
|
console.log("Smart token inserted into the ApiKey collection");
|
|
347
346
|
}
|
|
348
347
|
|
|
348
|
+
|
|
349
349
|
module.exports = {
|
|
350
350
|
saveDataJobsToCMS,
|
|
351
351
|
saveJobsDescriptionsAndLocationToCMS,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
const { fetch } = require('wix-fetch');
|
|
2
2
|
const { items: wixData } = require('@wix/data');
|
|
3
3
|
|
|
4
|
-
async function makeSmartRecruitersRequest(path) {
|
|
4
|
+
async function makeSmartRecruitersRequest(path,token) {
|
|
5
5
|
// const baseUrl = 'https://api.smartrecruiters.com'; // PROD
|
|
6
6
|
const baseUrl = 'https://aoxley54.wixstudio.com/external-template/_functions'; // TEST
|
|
7
7
|
const fullUrl = `${baseUrl}${path}`;
|
|
8
|
-
|
|
9
|
-
console.log("token is : ", token);
|
|
8
|
+
|
|
10
9
|
//console.log(`Making request to: ${fullUrl}`);
|
|
11
10
|
try {
|
|
12
11
|
const response = await fetch(fullUrl, {
|
|
@@ -37,6 +36,7 @@ async function fetchPositionsFromSRAPI() {
|
|
|
37
36
|
let nextPageId = null; // Start with no page ID for the first request
|
|
38
37
|
let pageCount = 0;
|
|
39
38
|
const MAX_PAGES = 30 // Safety limit to prevent infinite loops
|
|
39
|
+
const token = await getSmartTokenFromCMS();
|
|
40
40
|
|
|
41
41
|
console.log('Starting to fetch all positions with pagination...');
|
|
42
42
|
|
|
@@ -51,7 +51,7 @@ async function fetchPositionsFromSRAPI() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
console.log(`Fetching page ${pageCount} with path: ${apiPath}`);
|
|
54
|
-
const response = await makeSmartRecruitersRequest(apiPath);
|
|
54
|
+
const response = await makeSmartRecruitersRequest(apiPath,token);
|
|
55
55
|
|
|
56
56
|
// Add positions from this page to our collection
|
|
57
57
|
if (response.content && Array.isArray(response.content)) {
|