Skip to content

Commit 74d971b

Browse files
issue-4688 : Added ongoing filter to challenges listing
1 parent de89e65 commit 74d971b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils/challenge/filter.js

+9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ function filterByStarted(challenge, state) {
130130
return moment(challenge.registrationStartDate).isBefore(Date.now());
131131
}
132132

133+
function filterByOngoing(challenge, state) {
134+
if (_.isUndefined(state.ongoing)) return true;
135+
const registrationPhase = (challenge.phases || []).filter(d => d.name === 'Registration')[0];
136+
const registrationEndDate = registrationPhase ? registrationPhase.scheduledEndDate
137+
: challenge.registrationEndDate;
138+
return moment(registrationEndDate).isBefore(Date.now());
139+
}
140+
133141
function filterByStatus(challenge, state) {
134142
if (!state.status) return true;
135143
return state.status.includes(challenge.status);
@@ -219,6 +227,7 @@ export function getFilterFunction(state) {
219227
&& filterByEndDate(challenge, state)
220228
&& filterByStartDate(challenge, state)
221229
&& filterByStarted(challenge, state)
230+
&& filterByOngoing(challenge, state)
222231
&& filterByRegistrationOpen(challenge, state);
223232
if (!test && state.or) {
224233
let pos = 0;

0 commit comments

Comments
 (0)