Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
cli: fix rad inbox clear output
Browse files Browse the repository at this point in the history
If multiple ids are specified for `rad inbox clear`, it would report
that only 1 item was cleared, when in fact multiple were.

This was found to be due to the SQL code returning a change count of
`1`. This is likely due to the way the statement is being reset each
time. The `sqlite` library does not seem to easily support the usage
of `IN` in a `WHERE` clause. So instead, the `count` is aggregated in
the loop and returned instead.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
  • Loading branch information
FintanH authored and cloudhead committed Apr 9, 2024
1 parent 8bf8719 commit 3556758
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion radicle-cli/examples/rad-inbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $ rad inbox show 1
```

``` ~alice
$ rad inbox clear
$ rad inbox clear 1 2
✓ Cleared 2 item(s) from your inbox
$ rad inbox
Your inbox is empty.
Expand Down
6 changes: 5 additions & 1 deletion radicle/src/node/notifications/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,16 @@ impl Store<Write> {
.db
.prepare("DELETE FROM `repository-notifications` WHERE rowid = ?")?;

// N.b. we need to keep the count manually since the change count
// will always be `1` because of each reset.
let mut count = 0;
for id in ids {
stmt.bind((1, *id as i64))?;
stmt.next()?;
stmt.reset()?;
count += self.db.change_count();
}
Ok(self.db.change_count())
Ok(count)
})
}

Expand Down

0 comments on commit 3556758

Please sign in to comment.