Skip to content

Commit 5e55888

Browse files
authored
Merge pull request #1794 from apiraino/fix-assignment-to-ghost
Allow ghost GH user to skip PR workqueue check
2 parents 05e40cb + a3f67b7 commit 5e55888

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/handlers/assign.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -766,16 +766,22 @@ async fn find_reviewer_from_names(
766766
// These are all ideas for improving the selection here. However, I'm not
767767
// sure they are really worth the effort.
768768

769-
// filter out team members without capacity
770-
let filtered_candidates = filter_by_capacity(db, &candidates)
771-
.await
772-
.expect("Error while filtering out team members");
773-
774-
if filtered_candidates.is_empty() {
775-
return Err(FindReviewerError::AllReviewersFiltered {
776-
initial: names.to_vec(),
777-
filtered: names.to_vec(),
778-
});
769+
// If we are trying to assign to the ghost GitHub user, bypass every check
770+
let mut filtered_candidates: HashSet<String> = HashSet::new();
771+
if candidates.contains("ghost") {
772+
filtered_candidates.insert("ghost".to_string());
773+
} else {
774+
// filter out team members without capacity
775+
filtered_candidates = filter_by_capacity(db, &candidates)
776+
.await
777+
.expect("Error while filtering out team members");
778+
779+
if filtered_candidates.is_empty() {
780+
return Err(FindReviewerError::AllReviewersFiltered {
781+
initial: names.to_vec(),
782+
filtered: names.to_vec(),
783+
});
784+
}
779785
}
780786

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

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

0 commit comments

Comments
 (0)