diff options
-rw-r--r-- | src/commands/db.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/commands/db.rs b/src/commands/db.rs index d750ede..ed8fdae 100644 --- a/src/commands/db.rs +++ b/src/commands/db.rs @@ -412,27 +412,21 @@ fn jobs(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()> { ]); let conn = conn_cfg.establish_connection()?; - let sel = schema::jobs::table + let mut sel = schema::jobs::table .inner_join(schema::submits::table) .inner_join(schema::endpoints::table) .inner_join(schema::packages::table) .into_boxed(); - let sel = if let Some(submit_uuid) = matches - .value_of("submit_uuid") - .map(uuid::Uuid::parse_str) - .transpose()? - { - sel.filter(schema::submits::uuid.eq(submit_uuid)) - } else { - sel - }; + if let Some(submit_uuid) = matches.value_of("submit_uuid").map(uuid::Uuid::parse_str).transpose()? { + sel = sel.filter(schema::submits::uuid.eq(submit_uuid)) + } // Filter for environment variables from the CLI // // If we get a filter for environment on CLI, we fetch all job ids that are associated with the // passed environment variables and make `sel` filter for those. - let sel = if let Some((name, val)) = matches.value_of("env_filter").map(crate::util::env::parse_to_env).transpose()? { + if let Some((name, val)) = matches.value_of("env_filter").map(crate::util::env::parse_to_env).transpose()? { debug!("Filtering for ENV: {} = {}", name, val); let jids = schema::envvars::table .filter({ @@ -445,16 +439,12 @@ fn jobs(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()> { .load::<i32>(&conn)?; debug!("Filtering for these IDs (because of env filter): {:?}", jids); - sel.filter(schema::jobs::dsl::id.eq_any(jids)) - } else { - sel - }; + sel = sel.filter(schema::jobs::dsl::id.eq_any(jids)); + } - let sel = if let Some(limit) = matches.value_of("limit").map(i64::from_str).transpose()? { - sel.limit(limit) - } else { - sel - }; + if let Some(limit) = matches.value_of("limit").map(i64::from_str).transpose()? { + sel = sel.limit(limit) + } let data = sel .order_by(schema::jobs::id.desc()) // required for the --limit implementation |