Skip to content

Commit 3d96801

Browse files
committed
Print number of PRs in queue in work show
1 parent aa8c528 commit 3d96801

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub mod rfcbot;
2323
pub mod team;
2424
mod team_data;
2525
pub mod triage;
26+
mod utils;
2627
pub mod zulip;
2728

2829
#[cfg(test)]

src/utils.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use std::borrow::Cow;
2+
3+
/// Pluralize (add an 's' sufix) to `text` based on `count`.
4+
pub fn pluralize(text: &str, count: usize) -> Cow<str> {
5+
if count == 1 {
6+
text.into()
7+
} else {
8+
format!("{}s", text).into()
9+
}
10+
}

src/zulip.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::handlers::docs_update::docs_update;
66
use crate::handlers::pr_tracking::get_assigned_prs;
77
use crate::handlers::project_goals::{self, ping_project_goals_owners};
88
use crate::handlers::Context;
9+
use crate::utils::pluralize;
910
use anyhow::{format_err, Context as _};
1011
use std::env;
1112
use std::fmt::Write as _;
@@ -291,7 +292,11 @@ async fn workqueue_commands(
291292
None => String::from("Not set (i.e. unlimited)"),
292293
};
293294

294-
let mut response = format!("`rust-lang/rust` PRs in your review queue: {prs}\n");
295+
let mut response = format!(
296+
"`rust-lang/rust` PRs in your review queue: {prs} ({} {})\n",
297+
prs.len(),
298+
pluralize("PR", prs.len())
299+
);
295300
writeln!(response, "Review capacity: {capacity}\n")?;
296301
writeln!(response, "*Note that only selected PRs that are assigned to you are considered as being in the review queue.*")?;
297302
response

0 commit comments

Comments
 (0)