Refactor: Minify

Pull in new dependencies for minification
This commit is contained in:
Matthias Beyer 2018-01-21 22:29:47 +01:00
parent 4bd156fdb3
commit 82b67115e6
3 changed files with 20 additions and 33 deletions

View file

@ -31,3 +31,4 @@ libimagstore = { version = "0.6.0", path = "../../../lib/core/libimagstore"
libimagrt = { version = "0.6.0", path = "../../../lib/core/libimagrt" } libimagrt = { version = "0.6.0", path = "../../../lib/core/libimagrt" }
libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror" } libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror" }
libimagtimetrack = { version = "0.6.0", path = "../../../lib/domain/libimagtimetrack" } libimagtimetrack = { version = "0.6.0", path = "../../../lib/domain/libimagtimetrack" }
libimagutil = { version = "0.6.0", path = "../../../lib/etc/libimagutil" }

View file

@ -30,6 +30,7 @@ extern crate libimagerror;
extern crate libimagstore; extern crate libimagstore;
extern crate libimagrt; extern crate libimagrt;
extern crate libimagtimetrack; extern crate libimagtimetrack;
extern crate libimagutil;
mod cont; mod cont;
mod day; mod day;

View file

@ -29,9 +29,10 @@ use libimagrt::runtime::Runtime;
use libimagtimetrack::timetracking::TimeTracking; use libimagtimetrack::timetracking::TimeTracking;
use libimagtimetrack::tag::TimeTrackingTag; use libimagtimetrack::tag::TimeTrackingTag;
use libimagtimetrack::timetrackingstore::*; use libimagtimetrack::timetrackingstore::*;
use libimagtimetrack::iter::get::GetTimeTrackIter;
use libimagtimetrack::iter::filter::has_end_time; use libimagtimetrack::iter::filter::has_end_time;
use libimagtimetrack::iter::filter::has_one_of_tags; use libimagtimetrack::iter::filter::has_one_of_tags;
use libimagutil::warn_result::*;
use libimagutil::debug_result::*;
pub fn stop(rt: &Runtime) -> i32 { pub fn stop(rt: &Runtime) -> i32 {
let (_, cmd) = rt.cli().subcommand(); let (_, cmd) = rt.cli().subcommand();
@ -74,41 +75,25 @@ pub fn stop(rt: &Runtime) -> i32 {
.collect() .collect()
}); });
let iter : GetTimeTrackIter = match rt.store().get_timetrackings() {
Ok(i) => i,
Err(e) => {
error!("Getting timetrackings failed");
trace_error(&e);
return 1
}
};
let filter = has_end_time.not().and(has_one_of_tags(&tags)); let filter = has_end_time.not().and(has_one_of_tags(&tags));
rt
.store()
.get_timetrackings()
.map_warn_err_str("Getting timetrackings failed")
.map_err_trace_exit_unwrap(1)
.trace_unwrap()
// Filter all timetrackings for the ones that are not yet ended. // Filter all timetrackings for the ones that are not yet ended.
iter.trace_unwrap() .filter(|e| filter.filter(e))
.filter_map(|elem| {
if filter.filter(&elem) { // for each of these timetrackings, end them
Some(elem) // for each result, print the backtrace (if any)
} else { .fold(0, |acc, mut elem| {
None elem.set_end_datetime(stop_time.clone())
} .map_dbg(|e| format!("Setting end time worked: {:?}", e))
.map(|_| acc)
.map_err_trace_exit_unwrap(1)
}) })
// for each of these timetrackings, end them
// for each result, print the backtrace (if any)
.fold(0, |acc, mut elem| match elem.set_end_datetime(stop_time.clone()) {
Err(e) => { // if there was an error
trace_error(&e); // trace
1 // set exit code to 1
},
Ok(_) => {
debug!("Setting end time worked: {:?}", elem);
// Keep the exit code
acc
}
})
} }