diff options
| author | Gokul <appu.yess@gmail.com> | 2023-04-10 19:50:25 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-10 16:50:25 +0100 |
| commit | e0c4ec5498c0645f8850e275cf247889ae1dd12e (patch) | |
| tree | 9edecf2204fe263e86be8fce7ea7584bc504d083 /src/command/client | |
| parent | Add some emacs movement keys (#857) (diff) | |
| download | atuin-e0c4ec5498c0645f8850e275cf247889ae1dd12e.zip | |
Atuin stats with day, month, week and year filter (#858)
* atuin stats with day, month and year
* fixed stats for week
* review suggestions
* rust formatted
Diffstat (limited to '')
| -rw-r--r-- | src/command/client/stats.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/command/client/stats.rs b/src/command/client/stats.rs index d730df47..5134f22f 100644 --- a/src/command/client/stats.rs +++ b/src/command/client/stats.rs @@ -82,6 +82,22 @@ impl Cmd { }; let history = if words.as_str() == "all" { db.list(FilterMode::Global, &context, None, false).await? + } else if words.trim() == "today" { + let start = Local::now().date().and_hms(0, 0, 0); + let end = start + Duration::days(1); + db.range(start.into(), end.into()).await? + } else if words.trim() == "month" { + let end = Local::now().date().and_hms(0, 0, 0); + let start = end - Duration::days(31); + db.range(start.into(), end.into()).await? + } else if words.trim() == "week" { + let end = Local::now().date().and_hms(0, 0, 0); + let start = end - Duration::days(7); + db.range(start.into(), end.into()).await? + } else if words.trim() == "year" { + let end = Local::now().date().and_hms(0, 0, 0); + let start = end - Duration::days(365); + db.range(start.into(), end.into()).await? } else { let start = parse_date_string(&words, Local::now(), settings.dialect.into())?; let end = start + Duration::days(1); |
