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.
This commit is contained in:
Henrik Tougaard 2025-01-21 18:48:54 +01:00
parent 05aec6f8d6
commit 05cfc8fc61
No known key found for this signature in database

View File

@ -89,7 +89,11 @@ impl WrappedStats {
// Error analysis
let mut command_errors: HashMap<String, (usize, usize)> = 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<String, usize> = HashMap::new();
let mut second_half_commands: HashMap<String, usize> = HashMap::new();