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:
parent
bca1e64dd3
commit
e0c4ec5498
1 changed files with 16 additions and 0 deletions
|
@ -82,6 +82,22 @@ impl Cmd {
|
||||||
};
|
};
|
||||||
let history = if words.as_str() == "all" {
|
let history = if words.as_str() == "all" {
|
||||||
db.list(FilterMode::Global, &context, None, false).await?
|
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 {
|
} else {
|
||||||
let start = parse_date_string(&words, Local::now(), settings.dialect.into())?;
|
let start = parse_date_string(&words, Local::now(), settings.dialect.into())?;
|
||||||
let end = start + Duration::days(1);
|
let end = start + Duration::days(1);
|
||||||
|
|
Loading…
Reference in a new issue