Skip to content
Snippets Groups Projects
Commit 9a6216ac authored by Nikos Marinos's avatar Nikos Marinos
Browse files

massive refactor of pdfconversion to accommodate knex.destroy

parent 9339b4d3
No related branches found
No related tags found
2 merge requests!90Dev,!89Shared data model
......@@ -13,7 +13,6 @@ async function seed() {
await Journal.upsertMulti(journals)
const users = config.get('users')
let counter = 0
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
for (const user of users) {
......@@ -31,11 +30,7 @@ async function seed() {
}
// if there are not null identities
if (user.identities.find(identity => identity !== null)) {
await new User(user).save().catch(() => {
counter += 1
logger.info(`User ${user.email} exists.`)
if (counter === users.length) process.exit()
})
await new User(user).save()
}
}
} catch (e) {
......
......@@ -48,6 +48,8 @@ async function getDeposits() {
'WAITING_FOR_PDF_CONVERSION',
'files',
).then(async resultSet => {
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
for (const manuscript of resultSet) {
await deposit(manuscript)
}
......@@ -60,6 +62,8 @@ async function getDeposits() {
await manuscript
.findByFieldValuesIn('pdf_deposit_state', pdfDepositStates, 'files')
.then(async resultSet => {
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
for (const manuscript of resultSet) {
logger.info(`Check status of conversion: ${manuscript.id}`)
await ncbiApiCall(
......@@ -166,9 +170,8 @@ async function processDeposit(manuscript, deposit) {
const filename = `${uuidv}.pdf`
const filePath = `/tmp/${filename}`
await getFile(s3_get_url, filePath)
.then(
async () =>
await uploadToMinio(filename, manuscript, filePath, item_size, item),
.then(async () =>
uploadToMinio(filename, manuscript, filePath, item_size, item),
)
.catch(async error => {
manuscript.pdfDepositState = 'RESULT_FAILED_TO_BE_RETRIEVED'
......
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