summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-11-02 11:23:48 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-11-06 20:35:18 +0100
commitf6483f54db37ce1ea612fec1d51d7735362129bd (patch)
treefa44ddd8b14f6f06c035559a49f425b5d4b173db
parentbe56f9fe75dad8fc23adf97d611fba84daf95ba0 (diff)
Add ID reporting in imag-timetrack
-rw-r--r--bin/domain/imag-timetrack/src/cont.rs9
-rw-r--r--bin/domain/imag-timetrack/src/day.rs3
-rw-r--r--bin/domain/imag-timetrack/src/list.rs3
-rw-r--r--bin/domain/imag-timetrack/src/month.rs3
-rw-r--r--bin/domain/imag-timetrack/src/start.rs19
-rw-r--r--bin/domain/imag-timetrack/src/stop.rs17
-rw-r--r--bin/domain/imag-timetrack/src/track.rs16
-rw-r--r--bin/domain/imag-timetrack/src/week.rs3
-rw-r--r--bin/domain/imag-timetrack/src/year.rs3
9 files changed, 57 insertions, 19 deletions
diff --git a/bin/domain/imag-timetrack/src/cont.rs b/bin/domain/imag-timetrack/src/cont.rs
index 1e81e7a..b9d34f1 100644
--- a/bin/domain/imag-timetrack/src/cont.rs
+++ b/bin/domain/imag-timetrack/src/cont.rs
@@ -81,11 +81,16 @@ pub fn cont(rt: &Runtime) -> i32 {
acc.and_then(|_| {
// create a new tracking with the same tag
- tracking
+ let val = tracking
.get_timetrack_tag()
.and_then(|tag| rt.store().create_timetracking_now(&tag))
.map(|_| 0)
- .map_err_trace()
+ .map_err_trace();
+
+ let _ = rt.report_touched(tracking.get_location())
+ .map_err_trace_exit_unwrap(1);
+
+ val
})
})
},
diff --git a/bin/domain/imag-timetrack/src/day.rs b/bin/domain/imag-timetrack/src/day.rs
index 378b89d..e2c05f8 100644
--- a/bin/domain/imag-timetrack/src/day.rs
+++ b/bin/domain/imag-timetrack/src/day.rs
@@ -103,6 +103,9 @@ pub fn day(rt: &Runtime) -> i32 {
let end = e.get_end_datetime()?;
debug!(" -> end = {:?}", end);
+ let _ = rt.report_touched(e.get_location())
+ .map_err_trace_exit_unwrap(1);
+
Ok((tag, start, end))
})
.trace_unwrap_exit(1)
diff --git a/bin/domain/imag-timetrack/src/list.rs b/bin/domain/imag-timetrack/src/list.rs
index 13de641..08545f6 100644
--- a/bin/domain/imag-timetrack/src/list.rs
+++ b/bin/domain/imag-timetrack/src/list.rs
@@ -162,6 +162,9 @@ pub fn list_impl(rt: &Runtime,
.collect();
tab.add_row(Row::new(cells));
+ let _ = rt.report_touched(e.get_location())
+ .map_err_trace_exit_unwrap(1);
+
Ok(tab)
})
})
diff --git a/bin/domain/imag-timetrack/src/month.rs b/bin/domain/imag-timetrack/src/month.rs
index 7a65f64..1ca7d68 100644
--- a/bin/domain/imag-timetrack/src/month.rs
+++ b/bin/domain/imag-timetrack/src/month.rs
@@ -118,6 +118,9 @@ pub fn month(rt: &Runtime) -> i32 {
let end = e.get_end_datetime()?;
debug!(" -> end = {:?}", end);
+ let _ = rt.report_touched(e.get_location())
+ .map_err_trace_exit_unwrap(1);
+
Ok((tag, start, end))
})
.trace_unwrap_exit(1)
diff --git a/bin/domain/imag-timetrack/src/start.rs b/bin/domain/imag-timetrack/src/start.rs
index abf18b9..f7db9e0 100644
--- a/bin/domain/imag-timetrack/src/start.rs
+++ b/bin/domain/imag-timetrack/src/start.rs
@@ -24,9 +24,9 @@ use failure::Error;
use libimagrt::runtime::Runtime;
use libimagerror::trace::trace_error;
+use libimagerror::trace::MapErrTrace;
use libimagtimetrack::tag::TimeTrackingTag;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
-use libimagerror::trace::MapErrTrace;
pub fn start(rt: &Runtime) -> i32 {
let (_, cmd) = rt.cli().subcommand();
@@ -49,11 +49,18 @@ pub fn start(rt: &Runtime) -> i32 {
.map(String::from)
.map(TimeTrackingTag::from)
.fold(0, |acc, ttt| {
- rt.store()
- .create_timetracking_at(&start, &ttt)
- .map_err_trace()
- .map(|_| acc)
- .unwrap_or(1)
+ match rt.store().create_timetracking_at(&start, &ttt) {
+ Err(e) => {
+ trace_error(&e);
+ 1
+ },
+ Ok(entry) => {
+ let _ = rt.report_touched(entry.get_location())
+ .map_err_trace_exit_unwrap(1);
+
+ acc
+ }
+ }
})
}
diff --git a/bin/domain/imag-timetrack/src/stop.rs b/bin/domain/imag-timetrack/src/stop.rs
index 539c80a..f46f666 100644
--- a/bin/domain/imag-timetrack/src/stop.rs
+++ b/bin/domain/imag-timetrack/src/stop.rs
@@ -34,7 +34,6 @@ use libimagtimetrack::timetrackingstore::*;
use libimagtimetrack::iter::filter::has_end_time;
use libimagtimetrack::iter::filter::has_one_of_tags;
use libimagutil::warn_result::*;
-use libimagutil::debug_result::*;
pub fn stop(rt: &Runtime) -> i32 {
let (_, cmd) = rt.cli().subcommand();
@@ -92,10 +91,18 @@ pub fn stop(rt: &Runtime) -> i32 {
// for each of these timetrackings, end them
// for each result, print the backtrace (if any)
.fold(0, |acc, mut elem| {
- elem.set_end_datetime(stop_time.clone())
- .map_dbg(|e| format!("Setting end time worked: {:?}", e))
- .map(|_| acc)
- .map_err_trace_exit_unwrap(1)
+ match elem.set_end_datetime(stop_time.clone()) {
+ Err(e) => {
+ trace_error(&e);
+ 1
+ }
+ Ok(_) => {
+ format!("Setting end time worked: {:?}", elem);
+ let _ = rt.report_touched(elem.get_location())
+ .map_err_trace_exit_unwrap(1);
+ acc
+ }
+ }
})
}
diff --git a/bin/domain/imag-timetrack/src/track.rs b/bin/domain/imag-timetrack/src/track.rs
index 0e70961..d8f7d7b 100644
--- a/bin/domain/imag-timetrack/src/track.rs
+++ b/bin/domain/imag-timetrack/src/track.rs
@@ -81,12 +81,16 @@ pub fn track(rt: &Runtime) -> i32 {
.unwrap() // enforced by clap
.map(String::from)
.map(TimeTrackingTag::from)
- .fold(0, |acc, ttt| {
- rt.store()
- .create_timetracking(&start, &stop, &ttt)
- .map_err_trace()
- .map(|_| acc)
- .unwrap_or(1)
+ .fold(0, |acc, ttt| match rt.store().create_timetracking(&start, &stop, &ttt) {
+ Err(e) => {
+ trace_error(&e);
+ 1
+ },
+ Ok(entry) => {
+ let _ = rt.report_touched(entry.get_location())
+ .map_err_trace_exit_unwrap(1);
+ acc
+ }
})
}
diff --git a/bin/domain/imag-timetrack/src/week.rs b/bin/domain/imag-timetrack/src/week.rs
index c8a7452..9779796 100644
--- a/bin/domain/imag-timetrack/src/week.rs
+++ b/bin/domain/imag-timetrack/src/week.rs
@@ -116,6 +116,9 @@ pub fn week(rt: &Runtime) -> i32 {
let end = e.get_end_datetime()?;
debug!(" -> end = {:?}", end);
+ let _ = rt.report_touched(e.get_location())
+ .map_err_trace_exit_unwrap(1);
+
Ok((tag, start, end))
})
.trace_unwrap_exit(1)
diff --git a/bin/domain/imag-timetrack/src/year.rs b/bin/domain/imag-timetrack/src/year.rs
index 2d5c70f..24fcfc1 100644
--- a/bin/domain/imag-timetrack/src/year.rs
+++ b/bin/domain/imag-timetrack/src/year.rs
@@ -116,6 +116,9 @@ pub fn year(rt: &Runtime) -> i32 {
let end = e.get_end_datetime()?;
debug!(" -> end = {:?}", end);
+ let _ = rt.report_touched(e.get_location())
+ .map_err_trace_exit_unwrap(1);
+
Ok((tag, start, end))
})
.trace_unwrap_exit(1)