@@ -30,11 +30,16 @@ export const ORDER_BY = {
30
30
*/
31
31
export function normalizeChallenge ( challenge , username ) {
32
32
const phases = challenge . allPhases || challenge . phases || [ ] ;
33
- let registrationOpen = phases . filter ( d => d . name === 'Registration' ) [ 0 ] ;
34
- if ( registrationOpen && registrationOpen . isOpen ) {
35
- registrationOpen = 'Yes' ;
36
- } else {
37
- registrationOpen = 'No' ;
33
+ const registration = phases . filter ( d => d . name === 'Registration' ) [ 0 ] ;
34
+ let registrationOpen = 'No' ;
35
+ let registrationStartDate ;
36
+ let registrationEndDate ;
37
+ if ( registration ) {
38
+ registrationStartDate = registration . actualStartDate || registration . scheduledStartDate ;
39
+ if ( registration . isOpen ) {
40
+ registrationOpen = 'Yes' ;
41
+ }
42
+ registrationEndDate = registration . actualEndDate || registration . scheduledEndDate ;
38
43
}
39
44
const groups = { } ;
40
45
if ( challenge . groups ) {
@@ -56,11 +61,16 @@ export function normalizeChallenge(challenge, username) {
56
61
if ( submissionEndTimestamp ) {
57
62
submissionEndTimestamp = submissionEndTimestamp . scheduledEndDate ;
58
63
}
64
+ const prizes = ( challenge . prizeSets [ 0 ] && challenge . prizeSets [ 0 ] . prizes ) || [ ] ;
59
65
_ . defaults ( challenge , {
60
66
communities : new Set ( [ COMPETITION_TRACKS [ challenge . legacy . track ] ] ) ,
61
67
groups,
62
68
registrationOpen,
63
69
submissionEndTimestamp,
70
+ registrationStartDate,
71
+ registrationEndDate,
72
+ totalPrize : prizes . reduce ( ( acc , prize ) => acc + prize . value , 0 ) ,
73
+ submissionEndDate : submissionEndTimestamp ,
64
74
users : username ? { [ username ] : true } : { } ,
65
75
} ) ;
66
76
}
0 commit comments