@@ -40,29 +40,45 @@ export default async (procedureIds) => {
40
40
} else if ( newBIoProcedure . currentStatus === 'Zurückgezogen' ) {
41
41
newBIoProcedure . voteDate = lastHistory . date ;
42
42
}
43
+
44
+ // check vote results
43
45
let voteResults ;
44
- bIoProcedure . history . some ( ( h ) => {
45
- if ( h . decision ) {
46
- return h . decision . some ( ( decision ) => {
47
- if ( decision . type === 'Namentliche Abstimmung' ) {
48
- const voteResultsRegEx = / ( \d { 1 , 3 } : \d { 1 , 3 } : \d { 1 , 3 } ) / ;
49
- const voteResultsProto = decision . comment . match ( voteResultsRegEx ) ;
50
- const vResults = voteResultsProto ? voteResultsProto [ 0 ] . split ( ':' ) : null ;
51
- voteResults = {
52
- yes : vResults ? vResults [ 0 ] : null ,
53
- no : vResults ? vResults [ 1 ] : null ,
54
- abstination : vResults ? vResults [ 2 ] : null ,
55
- notVote :
56
- deputiesNumber [ bIoProcedure . period ] -
57
- ( vResults ? vResults . reduce ( ( pv , cv ) => pv + parseInt ( cv , 10 ) , 0 ) : 0 ) ,
58
- } ;
59
- return true ;
60
- }
61
- return false ;
62
- } ) ;
63
- }
64
- return false ;
65
- } ) ;
46
+ if (
47
+ bIoProcedure . customData &&
48
+ bIoProcedure . customData . voteResults &&
49
+ ( bIoProcedure . customData . voteResults . yes ||
50
+ bIoProcedure . customData . voteResults . abstination ||
51
+ bIoProcedure . customData . voteResults . no )
52
+ ) {
53
+ voteResults = {
54
+ yes : bIoProcedure . customData . voteResults . yes ,
55
+ abstination : bIoProcedure . customData . voteResults . abstination ,
56
+ no : bIoProcedure . customData . voteResults . no ,
57
+ } ;
58
+ } else {
59
+ bIoProcedure . history . some ( ( h ) => {
60
+ if ( h . decision ) {
61
+ return h . decision . some ( ( decision ) => {
62
+ if ( decision . type === 'Namentliche Abstimmung' ) {
63
+ const voteResultsRegEx = / ( \d { 1 , 3 } : \d { 1 , 3 } : \d { 1 , 3 } ) / ;
64
+ const voteResultsProto = decision . comment . match ( voteResultsRegEx ) ;
65
+ const vResults = voteResultsProto ? voteResultsProto [ 0 ] . split ( ':' ) : null ;
66
+ voteResults = {
67
+ yes : vResults ? vResults [ 0 ] : null ,
68
+ no : vResults ? vResults [ 1 ] : null ,
69
+ abstination : vResults ? vResults [ 2 ] : null ,
70
+ notVote :
71
+ deputiesNumber [ bIoProcedure . period ] -
72
+ ( vResults ? vResults . reduce ( ( pv , cv ) => pv + parseInt ( cv , 10 ) , 0 ) : 0 ) ,
73
+ } ;
74
+ return true ;
75
+ }
76
+ return false ;
77
+ } ) ;
78
+ }
79
+ return false ;
80
+ } ) ;
81
+ }
66
82
newBIoProcedure . voteResults = voteResults ;
67
83
68
84
newBIoProcedure . lastUpdateDate = lastHistory . date ;
0 commit comments