From 91013259d1f126b7ef9bfdbde86cc1b544cec62d Mon Sep 17 00:00:00 2001 From: Leandro Palazzolo Date: Sun, 19 Jan 2025 19:23:55 -0300 Subject: [PATCH 1/2] chore: use tasks instead of issues --- src/notification_triggered/src/main.rs | 14 +++++++++---- src/shared/src/functions.rs | 28 ++++++++++++++------------ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/notification_triggered/src/main.rs b/src/notification_triggered/src/main.rs index b72f519..237f3a7 100644 --- a/src/notification_triggered/src/main.rs +++ b/src/notification_triggered/src/main.rs @@ -44,8 +44,8 @@ async fn function_handler(event: LambdaEvent) -> Result) -> Result) -> Result "open", + (None, Some(_)) => "in-progress", + (Some(_), _) => "completed", + }) .execute(&mut *tx).await?; } sqlx::query( r#" - UPDATE issues + UPDATE tasks SET certified = true WHERE (certified = false OR certified IS NULL) AND 'kudos' = ANY(labels) "#, diff --git a/src/shared/src/functions.rs b/src/shared/src/functions.rs index d3ba93c..700c45a 100644 --- a/src/shared/src/functions.rs +++ b/src/shared/src/functions.rs @@ -180,23 +180,24 @@ pub async fn import_repositories( .enumerate() .map(|(i, _)| { format!( - "(${}, ${}, ${}, ${}, ${}, ${}, ${}, ${}, ${})", - i * 9 + 1, - i * 9 + 2, - i * 9 + 3, - i * 9 + 4, - i * 9 + 5, - i * 9 + 6, - i * 9 + 7, - i * 9 + 8, - i * 9 + 9, + "(${}, ${}, ${}, ${}, ${}, ${}, ${}, ${}, ${}, 'dev', ${})", + i * 10 + 1, + i * 10 + 2, + i * 10 + 3, + i * 10 + 4, + i * 10 + 5, + i * 10 + 6, + i * 10 + 7, + i * 10 + 8, + i * 10 + 9, + i * 10 + 10, ) }) .collect::>() .join(", "); let query_string = format!( - "INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, open, assignee_id, description) VALUES {} + "INSERT INTO tasks (number, title, labels, repository_id, issue_created_at, issue_closed_at, open, assignee_id, description, type, status) VALUES {} ON CONFLICT (repository_id, number) DO UPDATE SET title = EXCLUDED.title, @@ -205,7 +206,8 @@ pub async fn import_repositories( issue_closed_at = EXCLUDED.issue_closed_at, open = EXCLUDED.open, assignee_id = EXCLUDED.assignee_id, - description = EXCLUDED.description", + description = EXCLUDED.description, + status = EXCLUDED.status", placeholders ); @@ -240,7 +242,7 @@ pub async fn import_repositories( sqlx::query( r#" - UPDATE issues + UPDATE tasks SET certified = true WHERE (certified = false OR certified IS NULL) AND 'kudos' = ANY(labels) "#, From b05c50eb648be51b0fb13b85ed51a1e587903b96 Mon Sep 17 00:00:00 2001 From: Connor Campbell Date: Tue, 28 Jan 2025 00:22:21 +0000 Subject: [PATCH 2/2] chore: migrate insert column names --- src/notification_triggered/src/main.rs | 8 ++++---- src/shared/src/functions.rs | 17 +++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/notification_triggered/src/main.rs b/src/notification_triggered/src/main.rs index 237f3a7..8b8c74d 100644 --- a/src/notification_triggered/src/main.rs +++ b/src/notification_triggered/src/main.rs @@ -44,7 +44,7 @@ async fn function_handler(event: LambdaEvent) -> Result) -> Result) -> Result "open", + (None, Some(_)) => "in-progress", + (Some(_), _) => "completed", + }) } let issues_inserted_count = insert_issues_query @@ -243,8 +248,8 @@ pub async fn import_repositories( sqlx::query( r#" UPDATE tasks - SET certified = true - WHERE (certified = false OR certified IS NULL) AND 'kudos' = ANY(labels) + SET is_certified = true + WHERE (is_certified = false OR is_certified IS NULL) AND 'kudos' = ANY(labels) "#, ) .execute(&mut **tx)