Skip to content

Commit 766986f

Browse files
change challenge end date calculation logic
1 parent e3a1f8b commit 766986f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/common/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ function calculateChallengeEndDate (challenge, data) {
843843
if (!data) {
844844
data = challenge
845845
}
846-
let phase = data.phases.slice(-1)[0]
846+
let phase = data.phases[data.phases.length - 1]
847847
if (!phase || (!data.startDate && !challenge.startDate)) {
848848
return data.startDate || challenge.startDate
849849
}
@@ -854,7 +854,7 @@ function calculateChallengeEndDate (challenge, data) {
854854
let result = moment(data.startDate || challenge.startDate)
855855
while (phase) {
856856
result.add(phase.duration || 0, 'seconds')
857-
phase = phase.predecessor && phases[phase.predecessor]
857+
phase = phase.predecessor ? phases[phase.predecessor] : null
858858
}
859859
return result.toDate()
860860
}

0 commit comments

Comments
 (0)