Skip to content

Commit d310b05

Browse files
committed
Add work queue tracking in triagebot DB
1 parent c6fa165 commit d310b05

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,5 @@ CREATE table review_prefs (
335335
CREATE EXTENSION intarray;
336336
CREATE UNIQUE INDEX review_prefs_user_id ON review_prefs(user_id);
337337
",
338+
"ALTER TABLE review_prefs ADD COLUMN max_assigned_prs INTEGER DEFAULT NULL;",
338339
];

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,26 @@ pub struct ReviewPrefs {
132132
pub username: String,
133133
pub user_id: i64,
134134
pub assigned_prs: Vec<i32>,
135+
pub max_assigned_prs: Option<i32>,
135136
}
136137

137138
impl ReviewPrefs {
138139
fn to_string(&self) -> String {
140+
let capacity = if self.max_assigned_prs.is_some() {
141+
format!("{}", self.max_assigned_prs.expect("This can't fail"))
142+
} else {
143+
String::from("Not set (i.e. unlimited)")
144+
};
139145
let prs = self
140146
.assigned_prs
141147
.iter()
142148
.map(|pr| format!("#{}", pr))
143149
.collect::<Vec<String>>()
144150
.join(", ");
145-
format!("Username: {}\nAssigned PRs: {}", self.username, prs)
151+
format!(
152+
"Username: {}\nAssigned PRs: {}\nReview capacity: {}",
153+
self.username, prs, capacity
154+
)
146155
}
147156
}
148157

@@ -153,6 +162,7 @@ impl From<tokio_postgres::row::Row> for ReviewPrefs {
153162
username: row.get("username"),
154163
user_id: row.get("user_id"),
155164
assigned_prs: row.get("assigned_prs"),
165+
max_assigned_prs: row.get("max_assigned_prs"),
156166
}
157167
}
158168
}

0 commit comments

Comments
 (0)