@@ -53,30 +53,33 @@ module.exports = {
5353 } ,
5454 ] }
5555 } ) ;
56-
57- bd [ 0 ] . comments = allComments ? JSON . stringify ( allComments ) :[ ] ;
58- bd [ 0 ] . votes = allVotes ?JSON . stringify ( allVotes ) :[ ] ;
59- const votes = allVotes . reduce ( ( acc , vote ) => {
60- const votingPower = Number ( vote . drep_voting_power ) ;
61- if ( vote . vote_result ) {
62- acc . true = ( acc . true || 0 ) + votingPower ;
63- acc . yes = ( acc . yes || 0 ) + 1 ;
64- } else {
65- acc . false = ( acc . false || 0 ) + votingPower ;
66- acc . no = ( acc . no || 0 ) + 1 ;
67- }
68- acc . total = ( acc . total || 0 ) + votingPower ;
69- return acc ;
70- } , { } ) ;
56+ try {
57+ bd [ 0 ] . comments = allComments ? JSON . stringify ( allComments ) :[ ] ;
58+ bd [ 0 ] . votes = allVotes ?JSON . stringify ( allVotes ) :[ ] ;
59+ const votes = allVotes . reduce ( ( acc , vote ) => {
60+ const votingPower = Number ( vote . drep_voting_power ) ;
61+ if ( vote . vote_result ) {
62+ acc . true = ( acc . true || 0 ) + votingPower ;
63+ acc . yes = ( acc . yes || 0 ) + 1 ;
64+ } else {
65+ acc . false = ( acc . false || 0 ) + votingPower ;
66+ acc . no = ( acc . no || 0 ) + 1 ;
67+ }
68+ acc . total = ( acc . total || 0 ) + votingPower ;
69+ return acc ;
70+ } , { } ) ;
7171
72- bd [ 0 ] . total_votes = allVotes . length || 0 ;
73- bd [ 0 ] . total_voting_power = votes . total || 0 ;
74- bd [ 0 ] . total_yes_votes = votes . yes || 0 ;
75- bd [ 0 ] . total_yes_voting_power = votes . true || 0 ;
76- bd [ 0 ] . total_no_votes = votes . no || 0 ;
77- bd [ 0 ] . total_no_voting_power = votes . false || 0 ;
78- bd [ 0 ] . votes = JSON . stringify ( allVotes ) || [ ] ;
79- report . push ( bd [ 0 ] ) ;
72+ bd [ 0 ] . total_votes = allVotes . length || 0 ;
73+ bd [ 0 ] . total_voting_power = votes . total || 0 ;
74+ bd [ 0 ] . total_yes_votes = votes . yes || 0 ;
75+ bd [ 0 ] . total_yes_voting_power = votes . true || 0 ;
76+ bd [ 0 ] . total_no_votes = votes . no || 0 ;
77+ bd [ 0 ] . total_no_voting_power = votes . false || 0 ;
78+ bd [ 0 ] . votes = JSON . stringify ( allVotes ) || [ ] ;
79+ report . push ( bd [ 0 ] ) ;
80+ } catch ( error ) {
81+ console . log ( error ) ;
82+ }
8083 }
8184 }
8285 ctx . send ( report ) ;
0 commit comments