Skip to content

Commit

Permalink
update proposals algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Aug 21, 2018
1 parent 339b821 commit cd190f0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/controllers/api/statistics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ def index
# }
# ]
def proposals
result = MetaData.last&.validators&.map do |proposer|
count = Block.where("header->>'proposer' = ?", proposer).count
{
"validator": proposer,
count: count
}
end
validators = MetaData.last&.validators
result = Block.group("header ->> 'proposer'").count
.map { |k, v| { validator: k, count: v } }
.select { |b| validators.include?(b[:validator]) }

render json: {
result: result
Expand Down

0 comments on commit cd190f0

Please sign in to comment.