23
23
use crate :: {
24
24
config:: { AssignConfig , WarnNonDefaultBranchException } ,
25
25
github:: { self , Event , FileDiff , Issue , IssuesAction , Selection } ,
26
- handlers:: { pr_tracking :: has_user_capacity , Context , GithubClient , IssuesEvent } ,
26
+ handlers:: { Context , GithubClient , IssuesEvent } ,
27
27
interactions:: EditIssueBody ,
28
28
} ;
29
29
use anyhow:: { bail, Context as _} ;
@@ -39,7 +39,6 @@ use tracing as log;
39
39
#[ cfg( test) ]
40
40
mod tests {
41
41
mod tests_candidates;
42
- mod tests_db;
43
42
mod tests_from_diff;
44
43
}
45
44
@@ -564,22 +563,22 @@ pub(super) async fn handle_command(
564
563
}
565
564
let db_client = ctx. db . get ( ) . await ;
566
565
if is_self_assign ( & name, & event. user ( ) . login ) {
567
- let work_queue = has_user_capacity ( & db_client, & name) . await ;
568
- if work_queue. is_err ( ) {
569
- // NOTE: disabled for now, just log
570
- log:: warn!(
571
- "[#{}] PR self-assign failed, DB reported that user {} has no review capacity. Ignoring." ,
572
- issue. number,
573
- name
574
- ) ;
575
- // issue
576
- // .post_comment(
577
- // &ctx.github,
578
- // &REVIEWER_HAS_NO_CAPACITY.replace("{username}", &name),
579
- // )
580
- // .await?;
581
- // return Ok(());
582
- }
566
+ // let work_queue = has_user_capacity(&db_client, &name).await;
567
+ // if work_queue.is_err() {
568
+ // // NOTE: disabled for now, just log
569
+ // log::warn!(
570
+ // "[#{}] PR self-assign failed, DB reported that user {} has no review capacity. Ignoring.",
571
+ // issue.number,
572
+ // name
573
+ // );
574
+ // // issue
575
+ // // .post_comment(
576
+ // // &ctx.github,
577
+ // // &REVIEWER_HAS_NO_CAPACITY.replace("{username}", &name),
578
+ // // )
579
+ // // .await?;
580
+ // // return Ok(());
581
+ // }
583
582
584
583
name. to_string ( )
585
584
} else {
@@ -806,7 +805,7 @@ impl fmt::Display for FindReviewerError {
806
805
/// auto-assign groups, or rust-lang team names. It must have at least one
807
806
/// entry.
808
807
async fn find_reviewer_from_names (
809
- db : & DbClient ,
808
+ _db : & DbClient ,
810
809
teams : & Teams ,
811
810
config : & AssignConfig ,
812
811
issue : & Issue ,
@@ -845,24 +844,24 @@ async fn find_reviewer_from_names(
845
844
}
846
845
847
846
// filter out team members without capacity
848
- let filtered_candidates = filter_by_capacity ( db, & candidates)
849
- . await
850
- . expect ( "Error while filtering out team members" ) ;
851
-
852
- if filtered_candidates. is_empty ( ) {
853
- // NOTE: disabled for now, just log
854
- log:: info!( "[#{}] Filtered list of PR assignee is empty" , issue. number) ;
855
- // return Err(FindReviewerError::AllReviewersFiltered {
856
- // initial: names.to_vec(),
857
- // filtered: names.to_vec(),
858
- // });
859
- }
860
-
861
- log:: info!(
862
- "[#{}] Filtered list of candidates: {:?}" ,
863
- issue. number,
864
- filtered_candidates
865
- ) ;
847
+ // let filtered_candidates = filter_by_capacity(db, &candidates)
848
+ // .await
849
+ // .expect("Error while filtering out team members");
850
+ //
851
+ // if filtered_candidates.is_empty() {
852
+ // // NOTE: disabled for now, just log
853
+ // log::info!("[#{}] Filtered list of PR assignee is empty", issue.number);
854
+ // // return Err(FindReviewerError::AllReviewersFiltered {
855
+ // // initial: names.to_vec(),
856
+ // // filtered: names.to_vec(),
857
+ // // });
858
+ // }
859
+ //
860
+ // log::info!(
861
+ // "[#{}] Filtered list of candidates: {:?}",
862
+ // issue.number,
863
+ // filtered_candidates
864
+ // );
866
865
867
866
// Return unfiltered list of candidates
868
867
Ok ( candidates
@@ -872,32 +871,6 @@ async fn find_reviewer_from_names(
872
871
. to_string ( ) )
873
872
}
874
873
875
- /// Filter out candidates not having review capacity
876
- async fn filter_by_capacity (
877
- db : & DbClient ,
878
- candidates : & HashSet < & str > ,
879
- ) -> anyhow:: Result < HashSet < String > > {
880
- let usernames = candidates
881
- . iter ( )
882
- . map ( |c| * c)
883
- . collect :: < Vec < & str > > ( )
884
- . join ( "," ) ;
885
-
886
- let q = format ! (
887
- "
888
- SELECT username
889
- FROM review_prefs r
890
- JOIN users on users.user_id=r.user_id
891
- AND username = ANY('{{ {} }}')
892
- AND CARDINALITY(r.assigned_prs) < LEAST(COALESCE(r.max_assigned_prs,1000000))" ,
893
- usernames
894
- ) ;
895
- let result = db. query ( & q, & [ ] ) . await . context ( "Select DB error" ) ?;
896
- let candidates: HashSet < String > = result. iter ( ) . map ( |row| row. get ( "username" ) ) . collect ( ) ;
897
- log:: info!( "DB returned these candidates: {:?}" , candidates) ;
898
- Ok ( candidates)
899
- }
900
-
901
874
/// Returns a list of candidate usernames (from relevant teams) to choose as a reviewer.
902
875
fn candidate_reviewers_from_names < ' a > (
903
876
teams : & ' a Teams ,
0 commit comments