From 5ea601de3a44642fe6224392fab5e990a1b520a0 Mon Sep 17 00:00:00 2001 From: igennova Date: Thu, 25 Sep 2025 22:20:40 +0530 Subject: [PATCH] fix:showing last 6 months stats --- app/views/stats/index.html.erb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/stats/index.html.erb b/app/views/stats/index.html.erb index 5f680b95..bbcbed1c 100644 --- a/app/views/stats/index.html.erb +++ b/app/views/stats/index.html.erb @@ -545,9 +545,10 @@
<% - # Use all-time stats - max_count = @all_time_stats.map(&:count).max - total_days = @all_time_stats.length + # Use last 6 months of stats to keep the chart readable and fitting width + chart_stats = @all_time_stats.last(185) + max_count = chart_stats.map(&:count).max + total_days = chart_stats.length # Fixed dimensions graph_height = 240 @@ -633,7 +634,7 @@ /> - <% @all_time_stats.each_with_index do |stat, index| %> + <% chart_stats.each_with_index do |stat, index| %> <% bar_height = (stat.count.to_f / max_count * (graph_height - bottom_margin - 10)).round x_pos = left_margin + (index * (bar_width + bar_spacing))