Skip to content

Commit ebc4b34

Browse files
refactor handlePhasesAfterCancelling
1 parent 4f119e6 commit ebc4b34

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/common/phase-helper.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,12 @@ class ChallengePhaseHelper {
172172

173173
handlePhasesAfterCancelling(phases) {
174174
return _.map(phases, (phase) => {
175-
if (_.includes(["Registration", "Submission", "Checkpoint Submission"], phase.name)) {
176-
phase.isOpen = false;
177-
if (!_.isUndefined(phase.actualStartDate)) {
178-
phase.actualEndDate = moment().toDate().toISOString();
179-
}
180-
}
181-
return phase;
175+
const shouldClosePhase = _.includes(["Registration", "Submission", "Checkpoint Submission"], phase.name);
176+
return {
177+
...phase,
178+
isOpen: shouldClosePhase ? false : phase.isOpen,
179+
actualEndDate: shouldClosePhase ? moment().toDate().toISOString() : phase.actualEndDate,
180+
};
182181
});
183182
}
184183

src/services/ChallengeService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const {
4242
convertToISOString,
4343
} = require("../common/challenge-helper");
4444
const deepEqual = require("deep-equal");
45+
const { cloneDeep } = require("lodash");
4546

4647
const challengeDomain = new ChallengeDomain(GRPC_CHALLENGE_SERVER_HOST, GRPC_CHALLENGE_SERVER_PORT);
4748

0 commit comments

Comments
 (0)