Skip to content

Commit

Permalink
Stop converting nil graph values to zero
Browse files Browse the repository at this point in the history
Calling `to_f` or `to_i` on a nil value converts it zero.
This is not the desired behaviour as we'd rather show a gap in the graph
when the data is missing.
  • Loading branch information
leenagupte committed Nov 14, 2024
1 parent 5172917 commit 305b5c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/landing_page/block/statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def x_axis_keys
def rows
csv_headers[1..].map do |header|
values = csv_rows.map do |row|
row[header].to_f
row[header].to_f if row[header].present?
end

{
Expand Down
4 changes: 2 additions & 2 deletions spec/models/landing_page/block/statistics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
0.6,
0.7,
0.5,
0.0,
0.0,
nil,
nil,
0.5,
0.6,
],
Expand Down

0 comments on commit 305b5c1

Please sign in to comment.