'use strict'; const isProd = !!(process.env.NODE_ENV && process.env.NODE_ENV.toLowerCase() == "production"), axios = require('axios').default, token = isProd ? 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI1YTFkNmMwNWZmYjk0ZTc4NzVjNjhkZDkiLCJ1dCI6MSwiaWF0IjoxNjAyNzAwNzU2fQ.TVS6cpmvHivd4Du91M9ZCHNu5N0M4k3wOiSH11j4Azk' : 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI1YTFkNmMwNWZmYjk0ZTc4NzVjNjhkZDkiLCJ1dCI6MSwiaWF0IjoxNjAyNTkyNjEwfQ.xPj_sqHhrfWHjomsRVzjkP_wlMRZfErFdsjyJAy4aTg'; axios.defaults.baseURL = isProd ? 'http://agmission.agnav.com:7000' : 'http://$localhost:4000'; axios.defaults.headers.common['Authorization'] = `${token} `; axios.defaults.headers.post['Content-Type'] = 'application/json'; axios.defaults.headers.put['Content-Type'] = 'application/json'; const jobIds = isProd ? [ 5437, 5439, 5440, 5441, 5442, 5443, 5448, 5449, 5451, 5452, 5453, 5455, 5456, 5457, 5458, 5459, 5462 ] : [139]; // Running the app with NODE_ENV=development/production node main() .then(() => console.log("DONE")) .catch(err => () => console.log(err)); async function main() { for (let i = 0; i < jobIds.length; i++) { const jobId = jobIds[i]; let url = `/api/jobs/${jobId}?withItems=true&withLines=true`; try { // Load the job with items const resp = await axios.get(url); if (!resp.status == 200) continue; // Force update jobs with items to update missing array item's id (sprayAreas[..], ..) url = `/api/jobs/${jobId}`; await axios.put(url, { job: resp.data, updateItems: true, delSprItems: [] }); } catch (error) { console.log(error); } } }