Skip to content
Snippets Groups Projects
Commit 50206cb5 authored by Andrei Cioromila's avatar Andrei Cioromila
Browse files

refactor(helper-service): extract method to retrieve all manuscript versions

parent bdf316f5
No related branches found
No related tags found
3 merge requests!162Sprint 23 Features,!161Deploy S23 features and fixes,!159Hin 1153 status after review
......@@ -140,6 +140,14 @@ class Collection {
return fragmentHelper.hasReviewReport()
}
}
async getAllFragments({ FragmentModel }) {
return Promise.all(
this.collection.fragments.map(async fragment =>
FragmentModel.find(fragment),
),
)
}
}
module.exports = Collection
......@@ -103,8 +103,13 @@ module.exports = models => async (req, res) => {
await authorsTeam.save()
}
const fragments = await collectionHelper.getAllFragments({
FragmentModel: models.Fragment,
})
await collectionHelper.updateStatusByRecommendation({
recommendation: heRecommendation.recommendation,
fragments,
})
newFragment.submitted = Date.now()
......
/* eslint-disable no-return-await */
const uuid = require('uuid')
const { pick, get, set, has, isEmpty, last, findLast } = require('lodash')
const { pick, get, set, has, isEmpty, last } = require('lodash')
const config = require('config')
const { v4 } = require('uuid')
const logger = require('@pubsweet/logger')
......@@ -45,11 +44,9 @@ module.exports = models => async (req, res) => {
const collectionHelper = new Collection({ collection })
try {
fragments = await Promise.all(
collection.fragments.map(
async fragment => await models.Fragment.find(fragment),
),
)
fragments = await collectionHelper.getAllFragments({
FragmentModel: models.Fragment,
})
} catch (e) {
const notFoundError = await services.handleNotFoundError(e, 'Item')
fragments = []
......
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