Skip to content

Commit

Permalink
Fixed issue when filling holes in grouped supports query
Browse files Browse the repository at this point in the history
  • Loading branch information
jsperezg committed Sep 17, 2018
1 parent 42d4482 commit a658536
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
10 changes: 1 addition & 9 deletions app/controllers/concerns/dashboard/group_supports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ def fill_holes(grouped_votes)
(start_date(proposal.published_at.to_date)..end_date).each do |date|
missing_key = grouping_key_for(date)
next if grouped_votes.key? missing_key

previous_key = previous_key_for(date)
previous_value = if grouped_votes.key? previous_key
grouped_votes[previous_key]
else
0
end

grouped_votes[missing_key] = previous_value
grouped_votes[missing_key] = []
end

grouped_votes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def index

def accumulated_grouped_supports
grouped_votes = grouped_supports(:voted_at)
accumulate_supports(grouped_votes)
fill_holes(grouped_votes)
accumulate_supports(grouped_votes)
end

def supports
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dashboard/supports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def index

def accumulated_supports
grouped_votes = grouped_supports(:created_at)
accumulate_supports(grouped_votes)
fill_holes(grouped_votes)
accumulate_supports(grouped_votes)
end


Expand Down

0 comments on commit a658536

Please sign in to comment.