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