From c4b67ba30d191519a02d5ac32609f206b9c1457e Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 3 Oct 2021 17:58:14 -0400 Subject: [PATCH] Fix errors on stat page for empty site --- lib/philomena_web/templates/stat/index.html.slime | 2 +- lib/philomena_web/views/stat_view.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/philomena_web/templates/stat/index.html.slime b/lib/philomena_web/templates/stat/index.html.slime index 786bc55b..944c4063 100644 --- a/lib/philomena_web/templates/stat/index.html.slime +++ b/lib/philomena_web/templates/stat/index.html.slime @@ -33,7 +33,7 @@ elixir: p ' There are, on average, span.stat> - = number_with_delimiter(trunc(img_bucket["non_deleted"]["avg_comments"]["value"])) + = number_with_delimiter(trunc(img_bucket["non_deleted"]["avg_comments"]["value"] || 0)) ' comments on each image on the site. h3 Votes diff --git a/lib/philomena_web/views/stat_view.ex b/lib/philomena_web/views/stat_view.ex index c77297a0..9cdf4bc1 100644 --- a/lib/philomena_web/views/stat_view.ex +++ b/lib/philomena_web/views/stat_view.ex @@ -8,7 +8,7 @@ defmodule PhilomenaWeb.StatView do { %{"doc_count" => min_docs}, %{"doc_count" => max_docs} - } = Enum.min_max_by(data, & &1["doc_count"], fn -> %{"doc_count" => 0} end) + } = Enum.min_max_by(data, & &1["doc_count"], fn -> {%{"doc_count" => 0}, %{"doc_count" => 0}} end) graph_width = 950 graph_height = 475