File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -50,17 +50,35 @@ export default {
50
50
break ;
51
51
}
52
52
53
- let period = { $gte : 18 } ;
53
+ let period = { $gte : 19 } ;
54
54
let sort = { voteDate : - 1 } ;
55
55
if ( type === 'PREPARATION' ) {
56
56
period = { $gte : 19 } ;
57
57
sort = { lastUpdateDate : - 1 } ;
58
+ return ProcedureModel . find ( { currentStatus : { $in : currentStates } , period } )
59
+ . sort ( sort )
60
+ . skip ( offset )
61
+ . limit ( pageSize ) ;
58
62
}
59
63
60
- return ProcedureModel . find ( { currentStatus : { $in : currentStates } , period } )
61
- . sort ( sort )
64
+ const activeVotings = await ProcedureModel . find ( {
65
+ voteDate : { $exists : false } ,
66
+ currentStatus : { $in : currentStates } ,
67
+ period,
68
+ } )
69
+ . sort ( { lastUpdateDate : - 1 } )
62
70
. skip ( offset )
63
71
. limit ( pageSize ) ;
72
+
73
+ return ProcedureModel . find ( {
74
+ voteDate : { $exists : true } ,
75
+ currentStatus : { $in : currentStates } ,
76
+ period,
77
+ } )
78
+ . sort ( sort )
79
+ . skip ( offset - activeVotings . length > 0 ? offset - activeVotings . length : 0 )
80
+ . limit ( pageSize - activeVotings . length )
81
+ . then ( finishedVotings => [ ...activeVotings , ...finishedVotings ] ) ;
64
82
} ,
65
83
procedure : async ( parent , { id } , { ProcedureModel } ) =>
66
84
ProcedureModel . findOne ( { procedureId : id } ) ,
You can’t perform that action at this time.
0 commit comments