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
This commit is contained in:
Gokul 2023-04-10 19:50:25 +04:00 committed by GitHub
parent bca1e64dd3
commit e0c4ec5498
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);