Skip to content

Commit

Permalink
Fixed 2 bugs
Browse files Browse the repository at this point in the history
1.) git_directory was being set from scan_type value
2.) git_directory previously was not being set during workload updates.
  • Loading branch information
slackspace-io committed Apr 21, 2024
1 parent 2a7279b commit a11b670
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/database/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn return_workload(name: String, namespace: String) -> Result<Workload> {
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() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -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(()),
Expand Down

0 comments on commit a11b670

Please sign in to comment.