Commit 55fbf971 authored by ahamelers's avatar ahamelers
Browse files
parent d0ad4c1c
Pipeline #12829 passed with stages
in 5 minutes and 31 seconds
......@@ -16,9 +16,11 @@ const NCBI_RESPONSE_EXT = new RegExp(/\S+.ld.response.xml$/i)
let c = new Client()
;(async () => {
logger.info('running from NCBI check')
const beforeUpdate = Date.now()
const updatedManuscripts = await fromNcbi()
close(c)
logger.info(`from NCBI check was finished in ${Date.now() - beforeUpdate} ms`)
const successManuscripts = updatedManuscripts.filter(
m => m.ncbiState === 'success',
)
......@@ -26,15 +28,13 @@ let c = new Client()
logger.info('Sending grant data')
await createGrantLinks(successManuscripts)
}
logger.info(`from ncbi check was finished in ${Date.now() - beforeUpdate} ms`)
process.exit()
})()
function close(c) {
c.end()
ManuscriptAccess.knex().destroy()
c = null
logger.info('connection terminated')
process.exit()
}
function fromNcbi() {
......@@ -147,7 +147,6 @@ async function updateManuscriptNcbiStatus(fileName, response) {
const manuscriptId = fileName.split('.')[0].toUpperCase()
const manuscript = await ManuscriptAccess.selectById(manuscriptId)
if (!manuscript) {
// throw new Error(`manuscript ${manuscriptId} not found in db`)
logger.info(`manuscript ${manuscriptId} not found in db`)
return null
}
......@@ -171,6 +170,7 @@ async function updateManuscriptNcbiStatus(fileName, response) {
? newIds
: manuscript['meta,articleIds']
const newManuscript = await updateManuscript(manInput)
logger.info(`manuscript ${manuscriptId} updated`)
return newManuscript
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment