From b690ee4987fd8e9a3b7c5144437919fddfb8b4dd Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sat, 20 Aug 2022 15:28:09 +0300 Subject: [PATCH] add created at to the domain task Closes #5 --- src/domain.rs | 2 +- src/repo/fs.rs | 1 + src/repo/sqlite.rs | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/domain.rs b/src/domain.rs index 093a784..bcdbb1e 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -22,7 +22,7 @@ pub struct Task { pub project: Option, pub link: Option, pub dir_path: Option, - // created_at + pub created_at: time::OffsetDateTime, } pub struct CurrentTaskInfo { diff --git a/src/repo/fs.rs b/src/repo/fs.rs index 51bf54b..55f83fc 100644 --- a/src/repo/fs.rs +++ b/src/repo/fs.rs @@ -39,6 +39,7 @@ impl From for domain::Task { project: repo.group, link: repo.link, dir_path: repo.path.map(PathBuf::from), + created_at: time::OffsetDateTime::now_utc(), } } } diff --git a/src/repo/sqlite.rs b/src/repo/sqlite.rs index 89dbb51..022713b 100644 --- a/src/repo/sqlite.rs +++ b/src/repo/sqlite.rs @@ -14,9 +14,10 @@ struct Task { dir_path: Option, /* current: bool, - created_at: time::OffsetDateTime, finished_at: Option, */ + created_at: time::OffsetDateTime, + idx: i64, } @@ -27,6 +28,7 @@ impl From for domain::Task { project: repo.project, link: repo.link, dir_path: repo.dir_path.map(PathBuf::from), + created_at: repo.created_at, } } } @@ -43,9 +45,9 @@ impl<'r> TryFrom<&'r rusqlite::Row<'_>> for Task { dir_path: row.get("dir_path")?, /* current: row.get("current")?, - created_at: row.get("created_at")?, finished_at: row.get("finished_at")?, */ + created_at: row.get("created_at")?, idx: row.get("idx")?, }) }