diff --git a/src/notification_triggered/src/main.rs b/src/notification_triggered/src/main.rs index 65346e2..444594e 100644 --- a/src/notification_triggered/src/main.rs +++ b/src/notification_triggered/src/main.rs @@ -5,7 +5,6 @@ use shared::types::{AsyncLambdaPayload, KudosIssue, Res}; use sqlx::PgPool; use sqlx::Row; use std::env; -use std::fmt::format; /* Receives issue details as payload @@ -45,8 +44,8 @@ async fn function_handler(event: LambdaEvent) -> Result) -> Result) -> Result>() .join(", "); let query_string = format!( - "INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, open, assignee_id, certified, description) VALUES {}", + "INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, open, assignee_id, description) VALUES {}", placeholders ); @@ -219,7 +218,6 @@ pub async fn import_repositories( } else { None }) - .bind(issue.certified) .bind(issue.description) } @@ -230,6 +228,17 @@ pub async fn import_repositories( total_issues_imported += issues_inserted_count; } + + sqlx::query( + r#" + UPDATE issues + SET certified = true + WHERE certified = false AND 'kudos' = ANY(labels) + "#, + ) + .execute(&mut **tx) + .await?; + Ok(total_issues_imported) } diff --git a/src/shared/src/types.rs b/src/shared/src/types.rs index 98ea6fe..8a26abe 100644 --- a/src/shared/src/types.rs +++ b/src/shared/src/types.rs @@ -32,7 +32,7 @@ pub struct KudosIssue { pub issue_closed_at: Option>, pub creator: String, pub assignee: Option, - pub certified: bool, + // pub certified: bool, pub labels: Vec, pub description: Option, } @@ -54,7 +54,7 @@ impl From for KudosIssue { issue_closed_at: value.closed_at, creator: value.user.login, assignee: value.assignee.map(|assignee| assignee.login), - certified: labels.contains(&String::from("kudos")), + // certified: labels.contains(&String::from("kudos")), labels, description: value.body, }