Skip to content

Commit 124e287

Browse files
committed
Add work queue tracking in triagebot DB
Signed-off-by: apiraino <apiraino@users.noreply.github.com>
1 parent 4b11759 commit 124e287

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/db.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,7 @@ CREATE EXTENSION IF NOT EXISTS intarray;",
344344
"
345345
CREATE UNIQUE INDEX IF NOT EXISTS review_prefs_user_id ON review_prefs(user_id);
346346
",
347+
"
348+
ALTER TABLE review_prefs ADD COLUMN max_assigned_prs INTEGER DEFAULT NULL;
349+
",
347350
];

src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,25 @@ pub struct ReviewPrefs {
131131
pub username: String,
132132
pub user_id: i64,
133133
pub assigned_prs: Vec<i32>,
134+
pub max_assigned_prs: Option<i32>,
134135
}
135136

136137
impl ReviewPrefs {
137138
fn to_string(&self) -> String {
139+
let capacity = match self.max_assigned_prs {
140+
Some(max) => format!("{}", max),
141+
None => String::from("Not set (i.e. unlimited)"),
142+
};
138143
let prs = self
139144
.assigned_prs
140145
.iter()
141146
.map(|pr| format!("#{}", pr))
142147
.collect::<Vec<String>>()
143148
.join(", ");
144-
format!("Username: {}\nAssigned PRs: {}", self.username, prs)
149+
format!(
150+
"Username: {}\nAssigned PRs: {}\nReview capacity: {}",
151+
self.username, prs, capacity
152+
)
145153
}
146154
}
147155

@@ -152,6 +160,7 @@ impl From<tokio_postgres::row::Row> for ReviewPrefs {
152160
username: row.get("username"),
153161
user_id: row.get("user_id"),
154162
assigned_prs: row.get("assigned_prs"),
163+
max_assigned_prs: row.get("max_assigned_prs"),
155164
}
156165
}
157166
}

0 commit comments

Comments
 (0)