Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shared/utils/challenge-listing/buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getBuckets(userHandle) {
sorts: [
SORTS.MOST_RECENT,
SORTS.TIME_TO_REGISTER,
SORTS.PHASE_END_TIME,
SORTS.TIME_TO_SUBMIT,
SORTS.NUM_REGISTRANTS,
SORTS.NUM_SUBMISSIONS,
SORTS.PRIZE_HIGH_TO_LOW,
Expand Down
3 changes: 3 additions & 0 deletions src/shared/utils/challenge-listing/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function filterByGroupIds(challenge, state) {
function filterByRegistrationOpen(challenge, state) {
if (_.isUndefined(state.registrationOpen)) return true;
const isRegOpen = () => {
if (challenge.registrationOpen) {
return challenge.registrationOpen === 'Yes';
}
if (challenge.subTrack === 'MARATHON_MATCH') {
return challenge.status !== 'PAST';
}
Expand Down
18 changes: 12 additions & 6 deletions src/shared/utils/challenge-listing/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const SORTS = {
MOST_RECENT: 'most-recent',
NUM_REGISTRANTS: 'num-registrants',
NUM_SUBMISSIONS: 'num-submissions',
PHASE_END_TIME: 'phase-end-time',
PRIZE_HIGH_TO_LOW: 'prize-high-to-low',
TIME_TO_REGISTER: 'time-to-register',
TIME_TO_SUBMIT: 'time-to-submit',
Expand All @@ -33,10 +32,6 @@ export default {
func: (a, b) => b.numSubmissions - a.numSubmissions,
name: '# of submissions',
},
[SORTS.PHASE_END_TIME]: {
func: (a, b) => a.currentPhaseRemainingTime - b.currentPhaseRemainingTime,
name: 'Time to submit',
},
[SORTS.PRIZE_HIGH_TO_LOW]: {
func: (a, b) => b.totalPrize - a.totalPrize,
name: 'Prize high to low',
Expand All @@ -47,7 +42,18 @@ export default {
name: 'Time to register',
},
[SORTS.TIME_TO_SUBMIT]: {
func: (a, b) => a.submissionEndTimestamp - b.submissionEndTimestamp,
func: (a, b) => {
function nextSubEndDate(o) {
if (o.checkpointSubmissionEndDate && moment(o.checkpointSubmissionEndDate).isAfter()) {
return o.checkpointSubmissionEndDate;
}
return o.submissionEndDate;
}

let aDate = nextSubEndDate(a);
let bDate = nextSubEndDate(b);
return (moment(aDate).isBefore()) ? 1 : (moment(bDate).isBefore()) ? -1 : moment(aDate).diff(bDate);
},
name: 'Time to submit',
},
[SORTS.TITLE_A_TO_Z]: {
Expand Down