summaryrefslogtreecommitdiffstats
path: root/src/db/subscriptions.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
commit3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch)
tree7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /src/db/subscriptions.rs
parent9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff)
downloadaur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz
aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip
rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off
rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three.
Diffstat (limited to 'src/db/subscriptions.rs')
-rw-r--r--src/db/subscriptions.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/db/subscriptions.rs b/src/db/subscriptions.rs
index fc17de3..5b31f48 100644
--- a/src/db/subscriptions.rs
+++ b/src/db/subscriptions.rs
@@ -1,6 +1,6 @@
use rusqlite::{params, OptionalExtension, Row};
-use crate::db::*;
+use crate::db::{Db, SubscriptionState, Writer};
use crate::error::Result;
use crate::time;
@@ -51,13 +51,9 @@ pub fn list_subscriptions(db: &Db) -> Result<Vec<Subscription>> {
pub fn get_subscription(db: &Db, pkgbase: &str) -> Result<Option<Subscription>> {
db.read(|c| {
- c.query_row(
- &format!("SELECT {SUB_COLS} FROM subscription WHERE pkgbase = ?1"),
- params![pkgbase],
- row_to_sub,
- )
- .optional()
- .map_err(Into::into)
+ c.query_row(&format!("SELECT {SUB_COLS} FROM subscription WHERE pkgbase = ?1"), params![pkgbase], row_to_sub)
+ .optional()
+ .map_err(Into::into)
})
}
@@ -83,17 +79,14 @@ pub fn subscribe(writer: &Writer, repo_id: i64, pkgbase: &str, aur_url: &str) ->
pub fn set_subscription_state(writer: &Writer, pkgbase: &str, state: SubscriptionState) -> Result<()> {
let (p, s) = (pkgbase.to_string(), state.to_string());
writer.tx(move |tx| {
- tx.execute(
- "UPDATE subscription SET state=?1 WHERE pkgbase=?2",
- params![s, p],
- )?;
+ tx.execute("UPDATE subscription SET state=?1 WHERE pkgbase=?2", params![s, p])?;
Ok(())
})
}
pub fn note_check(writer: &Writer, pkgbase: &str, next_check_at: &str, err: Option<&str>) -> Result<()> {
let (p, n) = (pkgbase.to_string(), next_check_at.to_string());
- let e = err.map(|s| s.to_string());
+ let e = err.map(std::string::ToString::to_string);
let at = time::now();
writer.tx(move |tx| {
tx.execute(
@@ -120,4 +113,3 @@ pub fn due_subscriptions(db: &Db, now: &str) -> Result<Vec<Subscription>> {
Ok(out)
})
}
-