From 305b5c1db118284bcc27f827050cb0db1a6744db Mon Sep 17 00:00:00 2001 From: Leena Gupte Date: Thu, 14 Nov 2024 14:45:53 +0000 Subject: [PATCH] Stop converting nil graph values to zero 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. --- app/models/landing_page/block/statistics.rb | 2 +- spec/models/landing_page/block/statistics_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/landing_page/block/statistics.rb b/app/models/landing_page/block/statistics.rb index 425a5da2e0..4acdb10a60 100644 --- a/app/models/landing_page/block/statistics.rb +++ b/app/models/landing_page/block/statistics.rb @@ -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 { diff --git a/spec/models/landing_page/block/statistics_spec.rb b/spec/models/landing_page/block/statistics_spec.rb index 4ea9ec063f..ea74fabb01 100644 --- a/spec/models/landing_page/block/statistics_spec.rb +++ b/spec/models/landing_page/block/statistics_spec.rb @@ -89,8 +89,8 @@ 0.6, 0.7, 0.5, - 0.0, - 0.0, + nil, + nil, 0.5, 0.6, ],