Skip to content

Commit

Permalink
Add work queue tracking in triagebot DB
Browse files Browse the repository at this point in the history
  • Loading branch information
apiraino committed Apr 3, 2024
1 parent c6fa165 commit d310b05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,5 @@ CREATE table review_prefs (
CREATE EXTENSION intarray;
CREATE UNIQUE INDEX review_prefs_user_id ON review_prefs(user_id);
",
"ALTER TABLE review_prefs ADD COLUMN max_assigned_prs INTEGER DEFAULT NULL;",
];
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,26 @@ pub struct ReviewPrefs {
pub username: String,
pub user_id: i64,
pub assigned_prs: Vec<i32>,
pub max_assigned_prs: Option<i32>,
}

impl ReviewPrefs {
fn to_string(&self) -> String {
let capacity = if self.max_assigned_prs.is_some() {
format!("{}", self.max_assigned_prs.expect("This can't fail"))
} else {
String::from("Not set (i.e. unlimited)")
};
let prs = self
.assigned_prs
.iter()
.map(|pr| format!("#{}", pr))
.collect::<Vec<String>>()
.join(", ");
format!("Username: {}\nAssigned PRs: {}", self.username, prs)
format!(
"Username: {}\nAssigned PRs: {}\nReview capacity: {}",
self.username, prs, capacity
)
}
}

Expand All @@ -153,6 +162,7 @@ impl From<tokio_postgres::row::Row> for ReviewPrefs {
username: row.get("username"),
user_id: row.get("user_id"),
assigned_prs: row.get("assigned_prs"),
max_assigned_prs: row.get("max_assigned_prs"),
}
}
}
Expand Down

0 comments on commit d310b05

Please sign in to comment.