sr-npm 1.7.27 → 1.7.29
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/collectionConsts.js +3 -9
- package/backend/data.js +7 -12
- package/package.json +2 -1
|
@@ -11,25 +11,19 @@ const COLLECTIONS_FIELDS = {
|
|
|
11
11
|
{ key: 'count', type: 'NUMBER' },
|
|
12
12
|
],
|
|
13
13
|
CITIES: [
|
|
14
|
-
{key:'title', type: 'TEXT'},
|
|
15
|
-
{ key: 'regionCode', type: 'TEXT' },
|
|
16
14
|
{ key: 'city', type: 'TEXT' },
|
|
17
|
-
{key:'
|
|
15
|
+
{key:'locationAddress', type: 'ADDRESS'},
|
|
18
16
|
{key:'count', type: 'NUMBER'},
|
|
19
17
|
{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
18
|
],
|
|
27
19
|
JOBS: [
|
|
28
20
|
{key:'location', type: 'OBJECT'},
|
|
21
|
+
{key:'locationAddress', type: 'ADDRESS'},
|
|
29
22
|
{key:'postingStatus', type: 'TEXT'},
|
|
30
23
|
{key:'country', type: 'TEXT'},
|
|
31
24
|
{key:'department', type: 'TEXT'},
|
|
32
25
|
{key:'language', type: 'TEXT'},
|
|
26
|
+
{key:'remote', type: 'BOOLEAN'},
|
|
33
27
|
{key:'jobDescription', type: 'OBJECT'},
|
|
34
28
|
{key:'cityText', type: 'TEXT'},
|
|
35
29
|
{key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'AmountOfJobsPerDepartment' } } },
|
package/backend/data.js
CHANGED
|
@@ -4,7 +4,7 @@ const { chunkedBulkOperation } = require('./utils');
|
|
|
4
4
|
const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
|
|
5
5
|
const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./collectionConsts');
|
|
6
6
|
const { secrets } = require("@wix/secrets");
|
|
7
|
-
const {
|
|
7
|
+
const { auth } = require('@wix/essentials');
|
|
8
8
|
|
|
9
9
|
// Utility function to normalize city names
|
|
10
10
|
function normalizeCityName(city) {
|
|
@@ -170,6 +170,7 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
|
|
|
170
170
|
let cityLocations = {};
|
|
171
171
|
let query = wixData.query("Jobs").limit(1000);
|
|
172
172
|
let results = await query.find();
|
|
173
|
+
const cityLocationAddress={}
|
|
173
174
|
let page = 1;
|
|
174
175
|
do {
|
|
175
176
|
console.log(`Page ${page}: ${results.items.length} jobs.`);
|
|
@@ -179,7 +180,8 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
|
|
|
179
180
|
throw new Error(`Job ${job._id} has no ${field} field`);
|
|
180
181
|
}
|
|
181
182
|
jobsPerField[job[field]] = (jobsPerField[job[field]] || 0) + 1;
|
|
182
|
-
if (field === 'cityText' && !cityLocations[job[field]]) {
|
|
183
|
+
if (field === 'cityText' && !cityLocationAddress[job[field]] && cityLocations[job[field]]) {
|
|
184
|
+
cityLocationAddress[job[field]] = job.locationAddress;
|
|
183
185
|
cityLocations[job[field]] = job.location;
|
|
184
186
|
}
|
|
185
187
|
}
|
|
@@ -191,23 +193,16 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
|
|
|
191
193
|
let toSave = [];
|
|
192
194
|
if (field === 'cityText') {
|
|
193
195
|
toSave = Object.entries(jobsPerField).map(([value, amount]) => {
|
|
196
|
+
const locAddress = cityLocationAddress[value] || {};
|
|
194
197
|
const loc = cityLocations[value] || {};
|
|
195
198
|
value = normalizeCityName(value);
|
|
196
199
|
|
|
197
200
|
return {
|
|
198
|
-
title: value,
|
|
199
201
|
_id: value.replace(/\s+/g, ''),
|
|
200
202
|
count: amount,
|
|
201
|
-
|
|
202
|
-
countryCode: loc.countryCode,
|
|
203
|
+
locationAddress: locAddress,
|
|
203
204
|
country: loc.country,
|
|
204
|
-
region: loc.region,
|
|
205
205
|
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
206
|
};
|
|
212
207
|
});
|
|
213
208
|
}
|
|
@@ -320,7 +315,7 @@ function fetchJobLocation(jobDetails) {
|
|
|
320
315
|
|
|
321
316
|
|
|
322
317
|
function getSmartToken() {
|
|
323
|
-
const elevatedGetSecretValue = elevate(secrets.getSecretValue);
|
|
318
|
+
const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
|
|
324
319
|
return elevatedGetSecretValue("x-smarttoken")
|
|
325
320
|
.then((secret) => {
|
|
326
321
|
return secret;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sr-npm",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.29",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@hisense-staging/velo-npm": "1.7.249",
|
|
21
21
|
"@wix/data": "^1.0.211",
|
|
22
|
+
"@wix/essentials": "^0.1.24",
|
|
22
23
|
"@wix/secrets": "1.0.53"
|
|
23
24
|
}
|
|
24
25
|
}
|