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

refactor(manuscript-manager): move fragments retrieval to strategy

parent 0bdef7e5
No related branches found
No related tags found
3 merge requests!196S25 - EiC submit revision,!189S25,!177Hin 230 eic request revision
......@@ -32,7 +32,7 @@ module.exports = models => async (req, res) => {
const { collectionId, fragmentId } = req.params
let collection, fragment, fragments
let collection, fragment
try {
collection = await models.Collection.find(collectionId)
......@@ -50,18 +50,6 @@ module.exports = models => async (req, res) => {
const collectionHelper = new Collection({ collection })
try {
fragments = await collectionHelper.getAllFragments({
FragmentModel: models.Fragment,
})
} catch (e) {
const notFoundError = await services.handleNotFoundError(e, 'Item')
fragments = []
return res.status(notFoundError.status).json({
error: notFoundError.message,
})
}
const authsome = authsomeHelper.getAuthsome(models)
const target = {
fragment,
......@@ -143,7 +131,6 @@ module.exports = models => async (req, res) => {
await strategies[role][recommendation].execute({
userId,
models,
fragments,
notification,
fragmentHelper,
collectionHelper,
......
module.exports = {
execute: async ({
userId,
fragments,
notification,
fragmentHelper,
collectionHelper,
newRecommendation,
}) => {
const fragments = await collectionHelper.collection.getFragments()
if (!collectionHelper.canHEMakeRecommendation(fragments, fragmentHelper)) {
throw new Error('Cannot publish without at least one reviewer report.')
}
......
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