Skip to content

Commit

Permalink
Merge pull request #42 from kudos-ink/feat/description
Browse files Browse the repository at this point in the history
[feat] Add issues description
  • Loading branch information
leapalazzolo authored Oct 14, 2024
2 parents 7059952 + 3ae7752 commit 6633479
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/notification_triggered/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async fn function_handler(event: LambdaEvent<AsyncLambdaPayload>) -> Result<Res,

let insert_count = sqlx::query(
r#"
INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, assignee_id, open, certified)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, assignee_id, open, certified, description)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $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,
certified = EXCLUDED.certified
certified = EXCLUDED.certified,
description = EXCLUDED.description
"#
)
.bind(&kudos_issue.number)
Expand All @@ -70,6 +71,7 @@ async fn function_handler(event: LambdaEvent<AsyncLambdaPayload>) -> Result<Res,
})
.bind(&kudos_issue.issue_closed_at.is_none())
.bind(&kudos_issue.certified)
.bind(&kudos_issue.description)
.execute(&mut *tx).await?.rows_affected();

tx.commit().await?;
Expand Down
24 changes: 13 additions & 11 deletions src/shared/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,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,
"(${}, ${}, ${}, ${}, ${}, ${}, ${}, ${}, ${}, ${})",
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, certified) VALUES {}",
"INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, open, assignee_id, certified, description) VALUES {}",
placeholders
);

Expand All @@ -222,6 +223,7 @@ pub async fn import_repositories(
None
})
.bind(issue.certified)
.bind(issue.description)
}

let issues_inserted_count = insert_issues_query
Expand Down
2 changes: 2 additions & 0 deletions src/shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct KudosIssue {
pub assignee: Option<String>,
pub certified: bool,
pub labels: Vec<String>,
pub description: Option<String>,
}

impl From<Issue> for KudosIssue {
Expand All @@ -55,6 +56,7 @@ impl From<Issue> for KudosIssue {
assignee: value.assignee.map(|assignee| assignee.login),
certified: labels.contains(&String::from("kudos")),
labels,
description: value.body,
}
}
}
Expand Down

0 comments on commit 6633479

Please sign in to comment.