@@ -7,79 +7,73 @@ import { sumBy } from 'lodash';
7
7
// import { phaseStartDate, phaseEndDate } from './helper';
8
8
9
9
export const SORTS = {
10
- // CURRENT_PHASE: 'current-phase',
10
+ CURRENT_PHASE : 'current-phase' ,
11
11
MOST_RECENT : 'updated' ,
12
12
MOST_RECENT_START_DATE : 'startDate' ,
13
13
// NUM_REGISTRANTS: 'num-registrants',
14
14
// NUM_SUBMISSIONS: 'num-submissions',
15
- // PRIZE_HIGH_TO_LOW: 'prize-high-to-low ',
16
- // TIME_TO_REGISTER: 'time-to-register ',
17
- // TIME_TO_SUBMIT: 'time-to-submit ',
15
+ PRIZE_HIGH_TO_LOW : 'overview.totalPrizes ' ,
16
+ TIME_TO_REGISTER : 'registrationEndDate ' ,
17
+ TIME_TO_SUBMIT : 'submissionEndDate ' ,
18
18
TITLE_A_TO_Z : 'name' ,
19
19
REVIEW_OPPORTUNITIES_TITLE_A_TO_Z : 'review-opportunities-title-a-to-z' ,
20
20
REVIEW_OPPORTUNITIES_PAYMENT : 'review-opportunities-payment' ,
21
21
REVIEW_OPPORTUNITIES_START_DATE : 'review-opportunities-start-date' ,
22
22
} ;
23
23
24
24
export default {
25
- // [SORTS.CURRENT_PHASE]: {
26
- // func: (a, b) => a.status.localeCompare(b.status),
27
- // name: 'Current phase',
28
- // },
25
+ [ SORTS . CURRENT_PHASE ] : {
26
+ func : ( a , b ) => a . status . localeCompare ( b . status ) ,
27
+ name : 'Current phase' ,
28
+ } ,
29
29
[ SORTS . MOST_RECENT ] : {
30
- // func: (a, b) => moment(b.registrationStartDate).diff(a.registrationStartDate),
31
30
name : 'Most recent' ,
32
31
order : 'desc' ,
33
32
} ,
34
33
[ SORTS . MOST_RECENT_START_DATE ] : {
35
34
name : 'Most recent' ,
36
35
order : 'desc' ,
37
36
} ,
38
- // [SORTS.NUM_REGISTRANTS]: {
39
- // func: (a, b) => b.numOfRegistrants - a.numOfRegistrants,
40
- // name: '# of registrants',
41
- // },
42
- // [SORTS.NUM_SUBMISSIONS]: {
43
- // func: (a, b) => b.numOfSubmissions - a.numOfSubmissions,
44
- // name: '# of submissions',
45
- // },
46
- // [SORTS.PRIZE_HIGH_TO_LOW]: {
47
- // func: (a, b) => b.totalPrize - a.totalPrize,
48
- // name: 'Prize high to low',
49
- // },
50
- // [SORTS.TIME_TO_REGISTER]: {
51
- // func: (a, b) => {
52
- // const aDate = moment(a.registrationEndDate || a.submissionEndTimestamp);
53
- // const bDate = moment(b.registrationEndDate || b.submissionEndTimestamp);
37
+ [ SORTS . PRIZE_HIGH_TO_LOW ] : {
38
+ func : ( a , b ) => b . totalPrize - a . totalPrize ,
39
+ name : 'Prize high to low' ,
40
+ order : 'desc' ,
41
+ } ,
42
+ [ SORTS . TIME_TO_REGISTER ] : {
43
+ func : ( a , b ) => {
44
+ const aDate = moment ( a . registrationEndDate || a . submissionEndTimestamp ) ;
45
+ const bDate = moment ( b . registrationEndDate || b . submissionEndTimestamp ) ;
54
46
55
- // if (aDate.isBefore() && bDate.isAfter()) return 1;
56
- // if (aDate.isAfter() && bDate.isBefore()) return -1;
57
- // if (aDate.isBefore() && bDate.isBefore()) return bDate.diff(aDate);
47
+ if ( aDate . isBefore ( ) && bDate . isAfter ( ) ) return 1 ;
48
+ if ( aDate . isAfter ( ) && bDate . isBefore ( ) ) return - 1 ;
49
+ if ( aDate . isBefore ( ) && bDate . isBefore ( ) ) return bDate . diff ( aDate ) ;
58
50
59
- // return aDate.diff(bDate);
60
- // },
61
- // name: 'Time to register',
62
- // },
63
- // [SORTS.TIME_TO_SUBMIT]: {
64
- // func: (a, b) => {
65
- // function nextSubEndDate(o) {
66
- // if (o.checkpointSubmissionEndDate && moment(o.checkpointSubmissionEndDate).isAfter()) {
67
- // return moment(o.checkpointSubmissionEndDate);
68
- // }
69
- // return moment(o.submissionEndTimestamp);
70
- // }
51
+ return aDate . diff ( bDate ) ;
52
+ } ,
53
+ name : 'Time to register' ,
54
+ order : 'desc' ,
55
+ } ,
56
+ [ SORTS . TIME_TO_SUBMIT ] : {
57
+ func : ( a , b ) => {
58
+ function nextSubEndDate ( o ) {
59
+ if ( o . checkpointSubmissionEndDate && moment ( o . checkpointSubmissionEndDate ) . isAfter ( ) ) {
60
+ return moment ( o . checkpointSubmissionEndDate ) ;
61
+ }
62
+ return moment ( o . submissionEndTimestamp ) ;
63
+ }
71
64
72
- // const aDate = nextSubEndDate(a);
73
- // const bDate = nextSubEndDate(b);
65
+ const aDate = nextSubEndDate ( a ) ;
66
+ const bDate = nextSubEndDate ( b ) ;
74
67
75
- // if (aDate.isBefore() && bDate.isAfter()) return 1;
76
- // if (aDate.isAfter() && bDate.isBefore()) return -1;
77
- // if (aDate.isBefore() && bDate.isBefore()) return bDate.diff(aDate);
68
+ if ( aDate . isBefore ( ) && bDate . isAfter ( ) ) return 1 ;
69
+ if ( aDate . isAfter ( ) && bDate . isBefore ( ) ) return - 1 ;
70
+ if ( aDate . isBefore ( ) && bDate . isBefore ( ) ) return bDate . diff ( aDate ) ;
78
71
79
- // return aDate.diff(bDate);
80
- // },
81
- // name: 'Time to submit',
82
- // },
72
+ return aDate . diff ( bDate ) ;
73
+ } ,
74
+ name : 'Time to submit' ,
75
+ order : 'desc' ,
76
+ } ,
83
77
[ SORTS . TITLE_A_TO_Z ] : {
84
78
// func: (a, b) => a.name.localeCompare(b.name),
85
79
name : 'Title A-Z' ,
0 commit comments