From 05cfc8fc61d82c2c9b6bb9f15c48352531a00756 Mon Sep 17 00:00:00 2001 From: Henrik Tougaard Date: Tue, 21 Jan 2025 18:48:54 +0100 Subject: [PATCH] Fix wrapped command if not full year If atuin has not been used the whole year, then the "Command Evolution" will be misleading, as the year is split 182 days after the first command. This change set the mid-point of the year midways between the first and last command in the year. --- crates/atuin/src/command/client/wrapped.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/atuin/src/command/client/wrapped.rs b/crates/atuin/src/command/client/wrapped.rs index 7fad19f5..b0079412 100644 --- a/crates/atuin/src/command/client/wrapped.rs +++ b/crates/atuin/src/command/client/wrapped.rs @@ -89,7 +89,11 @@ impl WrappedStats { // Error analysis let mut command_errors: HashMap = HashMap::new(); // (total_uses, errors) - let midyear = history[0].timestamp + Duration::days(182); // Split year in half + + // Find number of days commands have been collected + let days = + (history[history.len() - 1].timestamp.ordinal() - history[0].timestamp.ordinal()) / 2; + let midyear = history[0].timestamp + Duration::days(days.into()); // Split year in half let mut first_half_commands: HashMap = HashMap::new(); let mut second_half_commands: HashMap = HashMap::new();