Skip to content

Commit

Permalink
Merge pull request #1794 from apiraino/fix-assignment-to-ghost
Browse files Browse the repository at this point in the history
Allow ghost GH user to skip PR workqueue check
  • Loading branch information
jackh726 authored Apr 16, 2024
2 parents 05e40cb + a3f67b7 commit 5e55888
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/handlers/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,16 +766,22 @@ async fn find_reviewer_from_names(
// These are all ideas for improving the selection here. However, I'm not
// sure they are really worth the effort.

// filter out team members without capacity
let filtered_candidates = filter_by_capacity(db, &candidates)
.await
.expect("Error while filtering out team members");

if filtered_candidates.is_empty() {
return Err(FindReviewerError::AllReviewersFiltered {
initial: names.to_vec(),
filtered: names.to_vec(),
});
// If we are trying to assign to the ghost GitHub user, bypass every check
let mut filtered_candidates: HashSet<String> = HashSet::new();
if candidates.contains("ghost") {
filtered_candidates.insert("ghost".to_string());
} else {
// filter out team members without capacity
filtered_candidates = filter_by_capacity(db, &candidates)
.await
.expect("Error while filtering out team members");

if filtered_candidates.is_empty() {
return Err(FindReviewerError::AllReviewersFiltered {
initial: names.to_vec(),
filtered: names.to_vec(),
});
}
}

log::debug!("Filtered list of candidates: {:?}", filtered_candidates);
Expand All @@ -787,6 +793,7 @@ async fn find_reviewer_from_names(
.to_string())
}

// FIXME: this query probably needs to take into account when max_assigned_prs is null
/// Filter out candidates not having review capacity
async fn filter_by_capacity(
db: &DbClient,
Expand Down

0 comments on commit 5e55888

Please sign in to comment.