Skip to content

Commit 46014f7

Browse files
Merge pull request #466 from topcoder-platform/develop
Hot fixes
2 parents f9833ec + aaa009d commit 46014f7

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/common/helper.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -843,20 +843,22 @@ function calculateChallengeEndDate (challenge, data) {
843843
if (!data) {
844844
data = challenge
845845
}
846-
let phase = data.phases.slice(-1)[0]
847-
if (!phase || (!data.startDate && !challenge.startDate)) {
848-
return data.startDate || challenge.startDate
849-
}
850-
const phases = (challenge.phases || []).reduce((obj, elem) => {
851-
obj[elem.id] = elem
852-
return obj
853-
}, {})
854-
let result = moment(data.startDate || challenge.startDate)
855-
while (phase) {
856-
result.add(phase.duration || 0, 'seconds')
857-
phase = phase.predecessor && phases[phase.predecessor]
858-
}
859-
return result.toDate()
846+
let lastPhase = data.phases[data.phases.length - 1]
847+
return lastPhase.actualEndDate || lastPhase.scheduledEndDate
848+
// let phase = data.phases[data.phases.length - 1]
849+
// if (!phase || (!data.startDate && !challenge.startDate)) {
850+
// return data.startDate || challenge.startDate
851+
// }
852+
// const phases = (challenge.phases || []).reduce((obj, elem) => {
853+
// obj[elem.id] = elem
854+
// return obj
855+
// }, {})
856+
// let result = moment(data.startDate || challenge.startDate)
857+
// while (phase) {
858+
// result.add(phase.duration || 0, 'seconds')
859+
// phase = phase.predecessor ? phases[phase.predecessor] : null
860+
// }
861+
// return result.toDate()
860862
}
861863

862864
/**

src/services/ChallengeService.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,16 @@ async function searchChallenges (currentUser, criteria) {
590590
}
591591
},
592592
{ bool: { must: { match_phrase: { 'createdBy': currentUser.handle } } } },
593-
] : [])
593+
] : [
594+
{
595+
bool: {
596+
should: [
597+
{ bool: { must: { match_phrase: { 'status': constants.challengeStatuses.Active } } } },
598+
{ bool: { must: { match_phrase: { 'status': constants.challengeStatuses.Completed } } } },
599+
]
600+
}
601+
}
602+
])
594603
]
595604
}
596605
})

0 commit comments

Comments
 (0)