Skip to content

Commit

Permalink
Merge pull request #22 from kudos-ink/import-closed-issues
Browse files Browse the repository at this point in the history
import closed issues to keep metrics
  • Loading branch information
CJ13th authored Oct 2, 2024
2 parents 5a3da6a + 5b0d9fb commit 8453eaf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/notification_triggered/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async fn function_handler(event: LambdaEvent<AsyncLambdaPayload>) -> Result<Res,
tx.commit().await?;

Ok(Res {
message: format!("Insert count {}", insert_count),
message: format!("Insert/Update count {}", insert_count),
})
}

Expand Down
27 changes: 14 additions & 13 deletions src/shared/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub async fn import_repositories(
let stream = octocrab
.issues(repo_info.owner, repo_info.name)
.list()
.state(State::Open)
.state(State::All)
.per_page(100)
.send()
.await?
Expand All @@ -123,7 +123,6 @@ pub async fn import_repositories(
.try_collect()
.await?;

info!("Number of open issues: {}", filtered_issues.len());
if filtered_issues.is_empty() {
continue;
}
Expand All @@ -133,23 +132,24 @@ pub async fn import_repositories(
.enumerate()
.map(|(i, _)| {
format!(
"(${}, ${}, ${}, ${}, ${}, ${}, ${}, ${})",
i * 8 + 1,
i * 8 + 2,
i * 8 + 3,
i * 8 + 4,
i * 8 + 5,
i * 8 + 6,
i * 8 + 7,
i * 8 + 8,
"(${}, ${}, ${}, ${}, ${}, ${}, ${}, ${}, ${})",
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,
)
})
.collect::<Vec<_>>()
.join(", ");

let query_string = format!(
"INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, assignee_id, certified) VALUES {}",
placeholders
"INSERT INTO issues (number, title, labels, repository_id, issue_created_at, issue_closed_at, open, assignee_id, certified) VALUES {}",
placeholdersq
);

let username_to_id = get_username_map(tx).await?;
Expand All @@ -164,6 +164,7 @@ pub async fn import_repositories(
.bind(repo_id)
.bind(issue.issue_created_at)
.bind(issue.issue_closed_at)
.bind(issue.issue_closed_at.is_none())
.bind(if let Some(assignee) = issue.assignee {
username_to_id.get(&assignee)
} else {
Expand Down

0 comments on commit 8453eaf

Please sign in to comment.