From 7b71e9a43692c7eeccd441050ab9913f99d86162 Mon Sep 17 00:00:00 2001 From: slightlycyborg Date: Fri, 26 Jul 2019 13:53:28 +0000 Subject: [PATCH] mix credo is now good --- .../controllers/chain_controller.ex | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex index 12b440f713..8819287acc 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex @@ -28,14 +28,6 @@ defmodule BlockScoutWeb.ChainController do transaction_stats = get_transaction_stats() - # Hack for render during testing - transaction_stats = - if length(transaction_stats) == 0 do - [%{number_of_transactions: 0}] - else - transaction_stats - end - chart_data_paths = %{ market: market_history_chart_path(conn, :show), transaction: transaction_history_chart_path(conn, :show) @@ -62,7 +54,15 @@ defmodule BlockScoutWeb.ChainController do def get_transaction_stats do stats_scale = date_range(1) - TransactionStats.by_date_range(stats_scale.earliest, stats_scale.latest) + transaction_stats = TransactionStats.by_date_range(stats_scale.earliest, stats_scale.latest) + + # Need datapoint for legend if none currently available. + if Enum.empty?(transaction_stats) == 0 do + [%{number_of_transactions: 0}] + else + transaction_stats + end + end def date_range(num_days) do