summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs3
-rw-r--r--src/commands/db.rs11
2 files changed, 14 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 71a2b67..0ecddfe 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -289,6 +289,9 @@ pub fn cli<'a>() -> App<'a> {
.value_name("LIMIT")
.about("Only list newest LIMIT jobs instead of all")
)
+
+ .arg(arg_older_than_date("List only jobs older than DATE"))
+ .arg(arg_newer_than_date("List only jobs newer than DATE"))
)
.subcommand(App::new("job")
diff --git a/src/commands/db.rs b/src/commands/db.rs
index ed8fdae..4ece20a 100644
--- a/src/commands/db.rs
+++ b/src/commands/db.rs
@@ -32,6 +32,7 @@ use log::debug;
use log::info;
use log::trace;
+use crate::commands::util::get_date_filter;
use crate::config::Configuration;
use crate::db::DbConnectionConfig;
use crate::db::models;
@@ -411,6 +412,8 @@ fn jobs(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()> {
"Version",
]);
let conn = conn_cfg.establish_connection()?;
+ let older_than_filter = get_date_filter("older_than", matches)?;
+ let newer_than_filter = get_date_filter("newer_than", matches)?;
let mut sel = schema::jobs::table
.inner_join(schema::submits::table)
@@ -442,6 +445,14 @@ fn jobs(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()> {
sel = sel.filter(schema::jobs::dsl::id.eq_any(jids));
}
+ if let Some(datetime) = older_than_filter.as_ref() {
+ sel = sel.filter(schema::submits::dsl::submit_time.lt(datetime))
+ }
+
+ if let Some(datetime) = newer_than_filter.as_ref() {
+ sel = sel.filter(schema::submits::dsl::submit_time.gt(datetime))
+ }
+
if let Some(limit) = matches.value_of("limit").map(i64::from_str).transpose()? {
sel = sel.limit(limit)
}