File tree Expand file tree Collapse file tree 2 files changed +26
-15
lines changed Expand file tree Collapse file tree 2 files changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -843,20 +843,22 @@ function calculateChallengeEndDate (challenge, data) {
843
843
if ( ! data ) {
844
844
data = challenge
845
845
}
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()
860
862
}
861
863
862
864
/**
Original file line number Diff line number Diff line change @@ -590,7 +590,16 @@ async function searchChallenges (currentUser, criteria) {
590
590
}
591
591
} ,
592
592
{ 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
+ ] )
594
603
]
595
604
}
596
605
} )
You can’t perform that action at this time.
0 commit comments