From 800ec41fadf58762ec30d864622806087cadc09c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 8 Sep 2021 13:29:32 +0200 Subject: Add --image flag to "db submits" command for filtering for a specific image Signed-off-by: Matthias Beyer Tested-by: Matthias Beyer --- src/cli.rs | 8 ++++++++ src/commands/db.rs | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 37df36c..5c4b399 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -255,6 +255,14 @@ pub fn cli<'a>() -> App<'a> { .value_name("HASH") .about("Limit listed submits to one commit hash") ) + .arg(Arg::new("image") + .required(false) + .multiple(false) + .long("image") + .takes_value(true) + .value_name("IMAGE") + .about("Limit listed submits to submits on IMAGE") + ) ) .subcommand(App::new("jobs") diff --git a/src/commands/db.rs b/src/commands/db.rs index f3a6721..38f4beb 100644 --- a/src/commands/db.rs +++ b/src/commands/db.rs @@ -341,6 +341,7 @@ fn submits(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()> let query = schema::submits::table .order_by(schema::submits::id.desc()) // required for the --limit implementation .inner_join(schema::githashes::table.on(schema::submits::repo_hash_id.eq(schema::githashes::id))) + .inner_join(schema::images::table) .into_boxed(); let query = if let Some(commithash) = commit.as_ref() { @@ -349,6 +350,12 @@ fn submits(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()> query }; + let query = if let Some(image) = matches.value_of("image") { + query.filter(schema::images::name.eq(image)) + } else { + query + }; + let submits = if let Some(pkgname) = matches.value_of("with_pkg").map(String::from) { // Get all submits which included the package, but were not necessarily made _for_ the package let query = query -- cgit v1.2.3