Skip to content

Commit

Permalink
handle: actually sweep PR numbers from database
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed Jul 10, 2024
1 parent 23ba6ec commit 961ee1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/command/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl Command {
/// TODO
#[instrument]
pub async fn handle_sweep(db: Arc<Database>) -> RoomMessageEventContent {
let db = db.write().await;
let mut db = db.write().await;
return_if_empty!(db);

let mut keep = vec![];
Expand All @@ -269,12 +269,14 @@ impl Command {
for pr in db.keys() {
// Check if open PR.
match pr_is_open(*pr).await {
Ok(true) => keep.push(pr),
Ok(false) => sweep.push(pr),
Ok(true) => keep.push(*pr),
Ok(false) => sweep.push(*pr),
Err(e) => return RoomMessageEventContent::text_plain(e.to_string()),
}
}

db.retain(|k, _| keep.contains(k));

let msg = format!("Keeping: {keep:?}, sweeping: {sweep:?}");
trace!(msg);
RoomMessageEventContent::text_plain(msg)
Expand Down

0 comments on commit 961ee1b

Please sign in to comment.