sr-npm 1.0.13 → 1.0.15
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.
|
@@ -3,6 +3,7 @@ const COLLECTIONS = {
|
|
|
3
3
|
CITIES: 'cities',
|
|
4
4
|
JOBS: 'Jobs',
|
|
5
5
|
COMPANY_ID: 'CompanyId',
|
|
6
|
+
TEMPLATE_TYPE: 'templateType',
|
|
6
7
|
}
|
|
7
8
|
const JOBS_COLLECTION_FIELDS = {
|
|
8
9
|
LOCATION: 'location',
|
|
@@ -64,6 +65,9 @@ const COLLECTIONS_FIELDS = {
|
|
|
64
65
|
COMPANY_ID: [
|
|
65
66
|
{key:'companyId', type: 'TEXT'},
|
|
66
67
|
],
|
|
68
|
+
TEMPLATE_TYPE: [
|
|
69
|
+
{key:'templateType', type: 'TEXT'},
|
|
70
|
+
],
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
|
|
@@ -34,6 +34,7 @@ async function fetchPositionsFromSRAPI() {
|
|
|
34
34
|
let page = 0;
|
|
35
35
|
const MAX_PAGES = 30 // Safety limit to prevent infinite loops
|
|
36
36
|
const companyId = await getCompanyIdFromCMS();
|
|
37
|
+
const templateType = await getTemplateTypeFromCMS();
|
|
37
38
|
console.log('Starting to fetch all positions with pagination...');
|
|
38
39
|
let offset=0;
|
|
39
40
|
|
|
@@ -42,7 +43,7 @@ async function fetchPositionsFromSRAPI() {
|
|
|
42
43
|
page++;
|
|
43
44
|
|
|
44
45
|
// Build the API path - first request has no page parameter, subsequent use nextPageId
|
|
45
|
-
const apiPath = `/v1/companies/${companyId}/postings?offset=${offset}`;
|
|
46
|
+
const apiPath = `/v1/companies/${companyId}/postings?offset=${offset}&destination=${templateType}`;
|
|
46
47
|
|
|
47
48
|
console.log(`Fetching page ${page} with path: ${apiPath}`);
|
|
48
49
|
const response = await makeSmartRecruitersRequest(apiPath);
|
|
@@ -107,6 +108,14 @@ async function getCompanyIdFromCMS() {
|
|
|
107
108
|
throw new Error('[getCompanyIdFromCMS], No companyId found');
|
|
108
109
|
}
|
|
109
110
|
}
|
|
111
|
+
async function getTemplateTypeFromCMS() {
|
|
112
|
+
const result = await wixData.query(COLLECTIONS.TEMPLATE_TYPE).limit(1).find();
|
|
113
|
+
if (result.items.length > 0) {
|
|
114
|
+
return result.items[0].templateType;
|
|
115
|
+
} else {
|
|
116
|
+
throw new Error('[getTemplateTypeFromCMS], No templateType found');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
110
119
|
|
|
111
120
|
|
|
112
121
|
module.exports = {
|