-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateLastIndexTime.js
39 lines (37 loc) · 1.21 KB
/
updateLastIndexTime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const axios = require("axios")
const moment = require("moment")
const URI = require('urijs');
function updateLastIndexingTime(start, ended, index) {
return new Promise((resolve, reject) => {
console.info('Updating lastIndexingTime')
axios({
url: URI("http://localhost:9200").segment('syncdata').segment("_doc").segment(index).toString(),
method: 'PUT',
auth: {
username: "",
password: ""
},
data: {
"lastBeganIndexingTime": start,
"lastEndedIndexingTime": ended
}
}).then((response) => {
if(response.status < 200 && response.status > 299) {
console.error('An error occured while updating lastIndexingTime')
return reject()
}
return resolve(false)
}).catch((err) => {
console.error(err)
console.error('An error occured while updating lastIndexingTime')
return reject(true)
})
})
}
let newLastBeganIndexingTime = moment().format('Y-MM-DDTHH:mm:ss');
setTimeout(() => {
let newLastEndedIndexingTime = moment().format('Y-MM-DDTHH:mm:ss');
updateLastIndexingTime(newLastBeganIndexingTime, newLastEndedIndexingTime, 'bhpclicensedprofessionals').then(() => {
console.log("Done");
})
}, 2000);