Skip to content

Commit 24c3ab3

Browse files
committed
Fix a problem with review summations during ongoing challenge
1 parent a902478 commit 24c3ab3

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/common/informixHelper.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const ReviewSummationService = require('../services/ReviewSummationService')
1414
* processed by the submission-processor-es code
1515
*/
1616
async function loadOnlineReviewDetails (authUser, submission) {
17-
const reviewSummation = {}
17+
let reviewSummation = null
1818
const reviewsCreated = []
1919

2020
// We can only load in OR details from the legacy submission ID.
@@ -58,21 +58,27 @@ async function loadOnlineReviewDetails (authUser, submission) {
5858

5959
submission.review.push(reviewToAdd)
6060
reviewsCreated.push(reviewToAdd)
61-
62-
reviewSummation.scoreCardId = dbReview.scorecard_id
63-
reviewSummation.submissionId = submission.id
64-
reviewSummation.aggregateScore = dbReview.aggregate_score
65-
reviewSummation.isPassing = dbReview.aggregate_score >= dbReview.min_score
66-
reviewSummation.reviewedDate = new Date(dbReview.create_date).toISOString()
61+
if (reviewSummation == null) {
62+
reviewSummation = {}
63+
reviewSummation.scoreCardId = dbReview.scorecard_id
64+
reviewSummation.submissionId = submission.id
65+
reviewSummation.aggregateScore = dbReview.aggregate_score
66+
reviewSummation.isPassing = dbReview.aggregate_score >= dbReview.min_score
67+
reviewSummation.reviewedDate = new Date(dbReview.create_date).toISOString()
68+
}
6769
}
6870

6971
// Add the reviews created to DynamoDB
7072
for (const review of reviewsCreated) {
73+
console.log(JSON.stringify(review, null, 4))
7174
await ReviewService.createReview(authUser, review)
7275
}
7376

7477
// Adds the review summation to DynamoDB
75-
await ReviewSummationService.createReviewSummation(authUser, reviewSummation)
78+
console.log(JSON.stringify(reviewSummation, null, 4))
79+
if (reviewSummation) {
80+
await ReviewSummationService.createReviewSummation(authUser, reviewSummation)
81+
}
7682
}
7783
return submission
7884
}

0 commit comments

Comments
 (0)