Skip to content
Snippets Groups Projects
Commit 07858b3e authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'HIN-729/841' into 'develop'

fix(mts): EQA and EQS get correct fragment files

See merge request !30
parents 1b448e05 e8255714
No related branches found
No related tags found
2 merge requests!34Sprint 17 features,!30fix(mts): EQA and EQS get correct fragment files
......@@ -17,30 +17,27 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => {
})
const s3 = new AWS.S3()
const asyncGetObject = promisify(s3.getObject.bind(s3))
const asyncListObjects = promisify(s3.listObjects.bind(s3))
return async ({ fragment, fileTypes, xmlFile, isEQA = false }) => {
const { id } = fragment
const { files = {} } = fragment
let packageName = get(xmlFile, 'name', '').replace('.xml', '')
if (isEQA) {
packageName = `ACCEPTED_${packageName}`
}
try {
const params = {
Bucket: s3Config.bucket,
Prefix: `${id}`,
}
const s3Items = await asyncListObjects(params)
if (s3Items) {
const s3FileIDs = Object.values(files)
.reduce((acc, f) => [...acc, ...f], [])
.map(f => f.id)
if (s3FileIDs) {
const s3Files = await Promise.all(
s3Items.Contents.map(content =>
s3FileIDs.map(fileID =>
asyncGetObject({
Bucket: s3Config.bucket,
Key: content.Key,
Key: fileID,
}),
),
)
if (s3Files) {
const packageOutput = fs.createWriteStream(`${packageName}.zip`)
const archive = archiver('zip')
......
......@@ -27,7 +27,7 @@ describe('MTS integration', () => {
})
it('should contain configured journal name ', () => {
const result = MTS.composeJson(mocks.fragment)
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