Skip to content
Snippets Groups Projects
Commit abeab643 authored by Sebastian Mihalache's avatar Sebastian Mihalache :hammer_pick:
Browse files

feat(mts-package): handled case for multiple versions

parent c834517e
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!156Develop,!148Hin 1098
...@@ -156,7 +156,7 @@ class Fragment { ...@@ -156,7 +156,7 @@ class Fragment {
recommendations.map(async rec => { recommendations.map(async rec => {
const user = await UserModel.find(rec.userId) const user = await UserModel.find(rec.userId)
let assignmentDate, submissionDate, isReviewer let assignmentDate, isReviewer
if (rec.recommendationType === confRecommendations.type.editor) { if (rec.recommendationType === confRecommendations.type.editor) {
if (user.id === collection.handlingEditor.id) { if (user.id === collection.handlingEditor.id) {
...@@ -174,19 +174,20 @@ class Fragment { ...@@ -174,19 +174,20 @@ class Fragment {
inv => inv.userId === user.id, inv => inv.userId === user.id,
) )
assignmentDate = reviewerInvitation.respondedOn assignmentDate = reviewerInvitation.respondedOn
submissionDate = rec.createdOn
isReviewer = true isReviewer = true
} }
return { return {
isReviewer, isReviewer,
submissionDate,
assignmentDate, assignmentDate,
email: user.email, email: user.email,
title: user.title, title: user.title,
recommendation: rec, recommendation: rec,
country: user.country,
lastName: user.lastName, lastName: user.lastName,
firstName: user.firstName, firstName: user.firstName,
submissionDate: rec.createdOn,
affiliation: user.affiliation,
} }
}), }),
) )
......
...@@ -94,16 +94,22 @@ module.exports = models => async (req, res) => { ...@@ -94,16 +94,22 @@ module.exports = models => async (req, res) => {
// the manuscript has not yet passed through the EQA process so we need to upload it to the FTP server // the manuscript has not yet passed through the EQA process so we need to upload it to the FTP server
if (isEditorInChief && recommendation === 'publish' && !hasEQA) { if (isEditorInChief && recommendation === 'publish' && !hasEQA) {
if (features.mts) { if (features.mts) {
const fragmentUsers = await fragmentHelper.getReviewersAndEditorsData({ collection.fragments.forEach(async fragmentId => {
collection, const fragment = await models.Fragment.find(fragmentId)
UserModel: models.User, fragmentHelper.fragment = fragment
}) const fragmentUsers = await fragmentHelper.getReviewersAndEditorsData(
{
await sendMTSPackage({ collection,
collection, UserModel: models.User,
fragment, },
isEQA: true, )
fragmentUsers,
await sendMTSPackage({
collection,
fragment,
isEQA: true,
fragmentUsers,
})
}) })
} }
......
...@@ -41,7 +41,7 @@ module.exports = { ...@@ -41,7 +41,7 @@ module.exports = {
}).then(() => { }).then(() => {
const packageName = get(xmlFile, 'name', '').replace('.xml', '') const packageName = get(xmlFile, 'name', '').replace('.xml', '')
const filename = isEQA const filename = isEQA
? `ACCEPTED_${packageName}.zip` ? `ACCEPTED_${packageName}.${fragment.version}.zip`
: `${packageName}.zip` : `${packageName}.zip`
return PackageManager.uploadFiles({ return PackageManager.uploadFiles({
...@@ -52,11 +52,3 @@ module.exports = { ...@@ -52,11 +52,3 @@ module.exports = {
}) })
}, },
} }
// const convertSample = filePath => {
// const fs = require('fs')
// const xml = fs.readFileSync(filePath, 'utf8')
// const result = convert.xml2js(xml, this.options)
// const newFile = filePath.replace('.xml', '.json')
// return fs.writeFile(newFile, JSON.stringify(result))
// }
...@@ -22,7 +22,7 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => { ...@@ -22,7 +22,7 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => {
const { files = {} } = fragment const { files = {} } = fragment
let packageName = get(xmlFile, 'name', '').replace('.xml', '') let packageName = get(xmlFile, 'name', '').replace('.xml', '')
if (isEQA) { if (isEQA) {
packageName = `ACCEPTED_${packageName}` packageName = `ACCEPTED_${packageName}.${fragment.version}`
} }
try { try {
const s3FileIDs = Object.values(files) const s3FileIDs = Object.values(files)
......
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
process.env.SUPPRESS_NO_CONFIG_WARNING = true
// const MTSService = require('../src/MTS')
// const mocks = require('./mocks')
jest.mock('xml-js', () => ({
json2xml: jest.fn(),
xml2js: jest.fn(),
}))
describe('MTS integration', () => {
// let MTS
// beforeEach(() => {
// MTS = new MTSService(mocks.config.defaultConfig)
// })
// it('should be instantiated', () => {
// const result = MTS
// expect(result).toBeDefined()
// })
// it('should return basic json for XML parsing', () => {
// const result = MTS.composeJson({})
// expect(result).toHaveProperty('article')
// })
// it('should contain configured journal name ', () => {
// const result = MTS.composeJson({ fragment: mocks.fragment })
// expect(result).toHaveProperty(
// 'article.front.journal-meta.journal-title-group.journal-title._text',
// 'Bioinorganic Chemistry and Applications',
// )
// })
})
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