From a3f67b707a79a65bb04a93dbdc03f53101c61000 Mon Sep 17 00:00:00 2001 From: apiraino Date: Tue, 16 Apr 2024 23:44:28 +0200 Subject: [PATCH] Allow ghost GH user to skip PR workqueue check --- src/handlers/assign.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/handlers/assign.rs b/src/handlers/assign.rs index cacf722d..35631030 100644 --- a/src/handlers/assign.rs +++ b/src/handlers/assign.rs @@ -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 = 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); @@ -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,