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

fix(fragment-helper): add fitlter before map

parent 7da2f4c2
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!156Develop,!153fix(mts-package): remove recommendations that have not been submitted
...@@ -158,57 +158,57 @@ class Fragment { ...@@ -158,57 +158,57 @@ class Fragment {
} = this.fragment } = this.fragment
const revAndEditorData = await Promise.all( const revAndEditorData = await Promise.all(
recommendations.map(async rec => { recommendations
if ( .filter(
rec.recommendationType === configRecommendations.type.review && rec =>
!rec.submittedOn rec.recommendationType === configRecommendations.type.editor ||
) { (rec.recommendationType === configRecommendations.type.review &&
return null rec.submittedOn),
} )
.map(async rec => {
const user = await UserModel.find(rec.userId) const user = await UserModel.find(rec.userId)
let assignmentDate, isReviewer let assignmentDate, isReviewer
if (rec.recommendationType === configRecommendations.type.editor) { if (rec.recommendationType === configRecommendations.type.editor) {
if (!collection.handlingEditor) { if (!collection.handlingEditor) {
throw new Error( throw new Error(
`Collection ${collection.id} does not have a Handling Editor`, `Collection ${collection.id} does not have a Handling Editor`,
) )
} }
if (user.id === collection.handlingEditor.id) { if (user.id === collection.handlingEditor.id) {
const editorInvitation = collection.invitations.find( const editorInvitation = collection.invitations.find(
inv => inv.userId === user.id,
)
assignmentDate = editorInvitation.respondedOn
} else {
assignmentDate = submitted
}
isReviewer = false
} else {
const reviewerInvitation = invitations.find(
inv => inv.userId === user.id, inv => inv.userId === user.id,
) )
assignmentDate = editorInvitation.respondedOn assignmentDate = reviewerInvitation.respondedOn
} else { isReviewer = true
assignmentDate = submitted
} }
isReviewer = false return {
} else { isReviewer,
const reviewerInvitation = invitations.find( assignmentDate,
inv => inv.userId === user.id, email: user.email,
) title: user.title,
assignmentDate = reviewerInvitation.respondedOn recommendation: rec,
isReviewer = true country: user.country,
} lastName: user.lastName,
firstName: user.firstName,
return { affiliation: user.affiliation,
isReviewer, submissionDate: rec.createdOn,
assignmentDate, }
email: user.email, }),
title: user.title,
recommendation: rec,
country: user.country,
lastName: user.lastName,
firstName: user.firstName,
affiliation: user.affiliation,
submissionDate: rec.createdOn,
}
}),
) )
return revAndEditorData.filter(Boolean) return revAndEditorData
} }
} }
......
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