From a11b670dbeef5e47ac1d2a3c13e9e511cd2d5736 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sun, 21 Apr 2024 12:22:24 +0200 Subject: [PATCH] Fixed 2 bugs 1.) git_directory was being set from scan_type value 2.) git_directory previously was not being set during workload updates. --- src/database/client.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/database/client.rs b/src/database/client.rs index c2a8c61..d5eea6a 100644 --- a/src/database/client.rs +++ b/src/database/client.rs @@ -44,7 +44,7 @@ pub fn return_workload(name: String, namespace: String) -> Result { current_version: row.get(8)?, latest_version: row.get(9)?, last_scanned: row.get(10)?, - git_directory: row.get(12)?, + git_directory: row.get(13)?, }) })?; if let Some(workload) = workload.next() { @@ -96,7 +96,7 @@ JOIN MaxLastScanned mls ON f.name = mls.name AND f.namespace = mls.namespace AND current_version: row.get(8)?, latest_version: row.get(9)?, last_scanned: row.get(10)?, - git_directory: row.get(12)?, + git_directory: row.get(13)?, }) })?; let mut result = Vec::new(); @@ -136,8 +136,8 @@ pub fn insert_workload(workload: &Workload, scan_id: i32) -> Result<()> { let conn = Connection::open("data.db")?; //get scan_id match conn.execute( - "INSERT INTO workloads (name, image, namespace, git_ops_repo, include_pattern, exclude_pattern, update_available, current_version, latest_version, last_scanned, scan_id, scan_type) - VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)", + "INSERT INTO workloads (name, image, namespace, git_ops_repo, include_pattern, exclude_pattern, update_available, current_version, latest_version, last_scanned, scan_id, scan_type, git_directory) + VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13)", [ &workload.name, &workload.image, @@ -151,6 +151,7 @@ pub fn insert_workload(workload: &Workload, scan_id: i32) -> Result<()> { &workload.last_scanned, &scan_id.to_string(), &workload.name, + &workload.git_directory.as_ref().map(String::as_str).unwrap_or_default(), ], ) { Ok(_) => Ok(()),