Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/notification_triggered/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ async fn function_handler(event: LambdaEvent<AsyncLambdaPayload>) -> Result<Res,

sqlx::query(
r#"
INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, assignee_id, open, description)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
INSERT INTO tasks (number, title, labels, repository_id, issue_created_at, issue_closed_at, assignee_id, open, description, type, status)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, 'dev', $10)
ON CONFLICT (repository_id, number)
DO UPDATE SET
title = EXCLUDED.title,
Expand All @@ -54,7 +54,8 @@ async fn function_handler(event: LambdaEvent<AsyncLambdaPayload>) -> Result<Res,
issue_closed_at = EXCLUDED.issue_closed_at,
assignee_id = EXCLUDED.assignee_id,
open = EXCLUDED.open,
description = EXCLUDED.description
description = EXCLUDED.description,
status = EXCLUDED.status
"#
)
.bind(&kudos_issue.number)
Expand All @@ -70,12 +71,17 @@ async fn function_handler(event: LambdaEvent<AsyncLambdaPayload>) -> Result<Res,
})
.bind(&kudos_issue.issue_closed_at.is_none())
.bind(&kudos_issue.description)
.bind(match (&kudos_issue.issue_closed_at, &kudos_issue.assignee) {
(None, None) => "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)
"#,
Expand Down
28 changes: 15 additions & 13 deletions src/shared/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
.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,
Expand All @@ -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
);

Expand Down Expand Up @@ -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)
"#,
Expand Down