aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/stats.rs
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2021-02-15 09:07:49 +0000
committerGitHub <noreply@github.com>2021-02-15 09:07:49 +0000
commit68c5ca9ecedb6001c61e933f2b7069c2e677213d (patch)
treeca04351dd4309e77b1091f9a7ce10a7b4ae10ade /src/command/stats.rs
parentUpdate README.md (diff)
downloadatuin-68c5ca9ecedb6001c61e933f2b7069c2e677213d.zip
use database trait instead of sqlite impl (#10)
small improvements
Diffstat (limited to 'src/command/stats.rs')
-rw-r--r--src/command/stats.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/command/stats.rs b/src/command/stats.rs
index ea5893f9..19079b8d 100644
--- a/src/command/stats.rs
+++ b/src/command/stats.rs
@@ -1,14 +1,14 @@
use std::collections::HashMap;
use chrono::prelude::*;
-use chrono::{Duration, Utc};
+use chrono::Duration;
use chrono_english::{parse_date_string, Dialect};
use cli_table::{format::Justify, print_stdout, Cell, Style, Table};
use eyre::{eyre, Result};
use structopt::StructOpt;
-use crate::local::database::{Database, Sqlite};
+use crate::local::database::Database;
use crate::local::history::History;
#[derive(StructOpt)]
@@ -70,7 +70,7 @@ fn compute_stats(history: &[History]) -> Result<()> {
}
impl Cmd {
- pub fn run(&self, db: &mut Sqlite) -> Result<()> {
+ pub fn run(&self, db: &mut impl Database) -> Result<()> {
match self {
Self::Day { words } => {
let words = if words.is_empty() {
@@ -79,10 +79,10 @@ impl Cmd {
words.join(" ")
};
- let start = parse_date_string(words.as_str(), Local::now(), Dialect::Us)?;
+ let start = parse_date_string(&words, Local::now(), Dialect::Us)?;
let end = start + Duration::days(1);
- let history = db.range(start.with_timezone(&Utc), end.with_timezone(&Utc))?;
+ let history = db.range(start.into(), end.into())?;
compute_stats(&history)?;