From 0d835983cecceb8133eab77634243ad674d7af16 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 23 Oct 2022 21:48:48 -0500 Subject: [PATCH] reports: fix error when report is empty. Fix an exception when a report is empty, for example when performing a tag search that returns no results: * https://betabooru.donmai.us/reports/posts?search[group]=uploader&search[tags]=does_not_exist --- app/components/time_series_component.rb | 2 +- .../time_series_component.html.erb | 4 +++- app/controllers/reports_controller.rb | 2 +- app/logical/danbooru/data_frame.rb | 6 +++++- test/functional/reports_controller_test.rb | 12 ++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/components/time_series_component.rb b/app/components/time_series_component.rb index 2bb42e805..506aff55c 100644 --- a/app/components/time_series_component.rb +++ b/app/components/time_series_component.rb @@ -18,7 +18,7 @@ class TimeSeriesComponent < ApplicationComponent def chart_height if x_axis != "date" - dataframe[x_axis].size * 30 + dataframe[x_axis]&.size.to_i * 30 end end diff --git a/app/components/time_series_component/time_series_component.html.erb b/app/components/time_series_component/time_series_component.html.erb index 2c4848be9..2bd2b2a23 100644 --- a/app/components/time_series_component/time_series_component.html.erb +++ b/app/components/time_series_component/time_series_component.html.erb @@ -6,7 +6,9 @@ <% end %> -<% if mode == :chart && x_axis.present? %> +<% if dataframe.empty? %> +

No results found. Try modifying your search or expanding your time range.

+<% elsif mode == :chart && x_axis.present? %>