1- use std:: { collections:: BTreeMap , ops:: AddAssign } ;
1+ use std:: {
2+ collections:: { BTreeMap , BTreeSet } ,
3+ ops:: AddAssign ,
4+ } ;
25
36use :: octocrab:: models:: { Author , teams:: RequestedTeam } ;
47use anyhow:: Context ;
@@ -18,7 +21,7 @@ use crate::{
1821 Error , ServerState ,
1922 github_accounts:: get_trainees,
2023 newtypes:: GithubLogin ,
21- octocrab:: { all_pages, octocrab} ,
24+ octocrab:: { all_pages, octocrab, octocrab_for_maybe_token } ,
2225 prs:: { PrWithReviews , fill_in_reviewers, get_prs} ,
2326 register:: { Attendance , get_register} ,
2427 sheets:: sheets_client,
@@ -331,3 +334,30 @@ pub async fn expected_attendance(
331334 }
332335 Json ( expected_attendance)
333336}
337+
338+ pub async fn started_itp (
339+ session : Session ,
340+ State ( server_state) : State < ServerState > ,
341+ OriginalUri ( original_uri) : OriginalUri ,
342+ ) -> Result < Json < BTreeSet < GithubLogin > > , Error > {
343+ let octocrab = octocrab ( & session, & server_state, original_uri) . await ;
344+ // Allow un-authenticated requests to this endpoint.
345+ let octocrab = if let Ok ( octocrab) = octocrab {
346+ octocrab
347+ } else {
348+ octocrab_for_maybe_token ( None ) ?
349+ } ;
350+ let prs = all_pages ( "pull requests" , & octocrab, async || {
351+ octocrab
352+ . pulls ( server_state. config . github_org , "Module-Onboarding" )
353+ . list ( )
354+ . send ( )
355+ . await
356+ } )
357+ . await ?;
358+ let usernames: BTreeSet < _ > = prs
359+ . into_iter ( )
360+ . filter_map ( |pr| Some ( GithubLogin :: from ( pr. user ?. login ) ) )
361+ . collect ( ) ;
362+ Ok ( Json ( usernames) )
363+ }
0 commit comments