Skip to content
Snippets Groups Projects
Commit 3bd060c2 authored by Yogmatee Roochun's avatar Yogmatee Roochun
Browse files

removed updateFileUrl method in data-access

parent 7be5cf46
No related branches found
No related tags found
2 merge requests!116Shared data model,!117Dev
......@@ -16,6 +16,7 @@ module.exports.createTaggersFiles = async function createTaggersFiles(
module.exports.upsertFileUrl = async function upsertFileUrl(
filesArr,
manuscriptId,
userId,
) {
const existingFiles = await FileModel.selectByManIdConvertedFiles(
manuscriptId,
......@@ -29,7 +30,8 @@ module.exports.upsertFileUrl = async function upsertFileUrl(
file => file.type === fileTypesArr[i],
)
if (existingFile) {
const filedb = await FileModel.updateFileUrl(existingFile.id, newFile.url)
existingFile.url = newFile.url
const filedb = await FileModel.update(existingFile, userId)
logger.info(filedb)
} else {
const filedb = await new FileModel(newFile).save({
......@@ -43,12 +45,14 @@ module.exports.upsertFileUrl = async function upsertFileUrl(
module.exports.upsertHtmlPrevFile = async function upsertHtmlPrevFile(
newFile,
manuscriptId,
userId,
) {
const existingFiles = await FileModel.selectByManuscriptId(manuscriptId)
const existingFile = existingFiles.find(file => file.type === 'source')
if (existingFile) {
const filedb = await FileModel.updateFileUrl(existingFile.id, newFile.url)
existingFile.url = newFile.url
const filedb = await FileModel.update(existingFile, userId)
logger.info(filedb)
} else {
const filedb = await new FileModel(newFile).save({
......
......@@ -149,7 +149,7 @@ module.exports.pushXML = async function pushXML(fileUrl, manuscriptId, userId) {
return obj
})
await db.upsertFileUrl(dbFilesArr, manuscriptId)
await db.upsertFileUrl(dbFilesArr, manuscriptId, userId)
Manuscript.update(
{ id: manuscriptId, pdfDepositState: 'WAITING_FOR_PDF_CONVERSION' },
......
......@@ -87,13 +87,6 @@ class File extends EpmcBaseModel {
return rows.map(rowToEntity)
}
static async updateFileUrl(id, fileurl) {
const fileUpdated = File.query()
.patch({ url: fileurl })
.where('id', id)
return fileUpdated
}
static async selectAll() {
const rows = await runQuery(
buildQuery
......
......@@ -22,6 +22,7 @@ xsweetConvert(
module.exports.xsweetConvert = async function xsweetConvert(
fileUrl,
manuscriptId,
userId,
) {
const options = {
method: 'POST',
......@@ -62,7 +63,7 @@ module.exports.xsweetConvert = async function xsweetConvert(
fileInfo.url = `/download/${uuid}${fileInfo.extension}`
delete fileInfo.extension
await db.upsertHtmlPrevFile(fileInfo, manuscriptId)
await db.upsertHtmlPrevFile(fileInfo, manuscriptId, userId)
logger.info('HTML converted file has been uploaded to Minio and to db')
} catch (err) {
throw err
......
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