Skip to content

Commit 627810e

Browse files
committed
randomize stalled ACPs
1 parent bf5dbac commit 627810e

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

tools/agenda-generator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ chrono = { version = "0.4", features = ["serde"] }
99
clap = { version = "4", features = ["derive"] }
1010
color-eyre = "0.6"
1111
itertools = "0.12"
12+
rand = "0.8.5"
1213
reqwest = { version = "0.11", features = ["blocking", "json"] }
1314
serde = { version = "1.0", features = ["derive"] }
1415
serde_json = "1.0"

tools/agenda-generator/src/generator.rs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use color_eyre::{
44
Section, SectionExt,
55
};
66
use itertools::Itertools;
7+
use rand::{seq::SliceRandom, thread_rng};
78
use reqwest::header::{AUTHORIZATION, USER_AGENT};
89
use serde::de::{DeserializeOwned, Deserializer};
910
use serde::Deserialize;
@@ -77,7 +78,7 @@ impl Generator {
7778
.repo("rust-lang/rust")
7879
.write(&mut self)?;
7980

80-
GithubQuery::new("new change proposal")
81+
let new_proposals = GithubQuery::new("new change proposal")
8182
.labels(&["api-change-proposal"])
8283
.repo("rust-lang/libs-team")
8384
.sort(Sort::Newest)
@@ -89,6 +90,8 @@ impl Generator {
8990
.repo("rust-lang/libs-team")
9091
.sort(Sort::LeastRecentlyUpdated)
9192
.take(5)
93+
.skip(new_proposals.iter())
94+
.shuffle(true)
9295
.write(&mut self)?;
9396

9497
writeln!(&mut self.agenda, "_Generated by [fully-automatic-rust-libs-team-triage-meeting-agenda-generator](https://github.com/rust-lang/libs-team/tree/main/tools/agenda-generator)_")?;
@@ -454,6 +457,8 @@ struct GithubQuery {
454457
repos: Vec<&'static str>,
455458
sort: Option<Sort>,
456459
count: Option<usize>,
460+
to_skip: Vec<String>,
461+
shuffle: bool,
457462
state: State,
458463
}
459464

@@ -490,7 +495,9 @@ impl GithubQuery {
490495
excluded_labels: vec![],
491496
repos: vec![],
492497
sort: None,
498+
to_skip: vec![],
493499
count: None,
500+
shuffle: false,
494501
state: State::Open,
495502
}
496503
}
@@ -515,6 +522,16 @@ impl GithubQuery {
515522
self
516523
}
517524

525+
fn shuffle(&mut self, shuffle: bool) -> &mut Self {
526+
self.shuffle = shuffle;
527+
self
528+
}
529+
530+
fn skip<'a>(&mut self, to_skip: impl Iterator<Item=&'a Issue>) -> &mut Self {
531+
self.to_skip = to_skip.map(|i| i.html_url.clone()).collect();
532+
self
533+
}
534+
518535
fn take(&mut self, count: usize) -> &mut Self {
519536
self.count = Some(count);
520537
self
@@ -525,7 +542,10 @@ impl GithubQuery {
525542
self
526543
}
527544

528-
fn write(&mut self, generator: &mut Generator) -> Result<()> {
545+
fn write(&mut self, generator: &mut Generator) -> Result<Vec<Issue>> {
546+
let mut all_issues = Vec::new();
547+
548+
529549
for repo in &self.repos {
530550
for labels in &self.labels {
531551
let cs_labels = labels.join(",");
@@ -547,8 +567,11 @@ impl GithubQuery {
547567
.all(|&label| issue.labels.iter().any(|x| x == label))
548568
})
549569
});
570+
let issues = issues.filter(|i| {
571+
!self.to_skip.iter().any(|s| *s == i.html_url)
572+
});
550573

551-
let issues: Vec<_> = issues.collect();
574+
let mut issues: Vec<_> = issues.collect();
552575

553576
if issues.is_empty() {
554577
continue;
@@ -575,18 +598,22 @@ impl GithubQuery {
575598
// labels = labels.join("` `"),
576599
// url = url,
577600
//)?;
578-
let issues = if let Some(count) = self.count {
579-
&issues[..count]
580-
} else {
581-
&issues[..]
582-
};
601+
602+
if self.shuffle {
603+
issues.shuffle(&mut thread_rng());
604+
}
605+
606+
if let Some(count) = self.count {
607+
issues.truncate(count);
608+
}
583609
generator.write_issues(self.name, &issues)?;
610+
all_issues.append(&mut issues);
584611
}
585612
}
586613

587614
writeln!(generator.agenda)?;
588615

589-
Ok(())
616+
Ok(all_issues)
590617
}
591618
}
592619

@@ -600,6 +627,7 @@ struct Issue {
600627
labels: Vec<String>,
601628
}
602629

630+
603631
fn escape(v: &str) -> String {
604632
let mut s = String::with_capacity(v.len() + 10);
605633
v.chars().for_each(|c| {

0 commit comments

Comments
 (0)