diff options
Diffstat (limited to 'src/db/notices.rs')
| -rw-r--r-- | src/db/notices.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/db/notices.rs b/src/db/notices.rs index 36263a4..795f736 100644 --- a/src/db/notices.rs +++ b/src/db/notices.rs @@ -1,18 +1,17 @@ use rusqlite::{params, OptionalExtension}; -use crate::db::*; +use crate::db::{Db, Writer}; use crate::error::Result; use crate::time; // ----------------------------------------------------------------- notice -- - pub fn put_notice_once( writer: &Writer, pkgbase_id: i64, kind: &str, severity: &str, - detail: serde_json::Value, + detail: &serde_json::Value, ) -> Result<Option<i64>> { let (k, s, d) = (kind.to_string(), severity.to_string(), detail.to_string()); let at = time::now(); @@ -54,11 +53,7 @@ pub fn list_notices(db: &Db, include_acknowledged: bool) -> Result<Vec<NoticeRow "SELECT n.id, b.name, n.kind, n.severity, n.detail_json, n.created_at, n.acknowledged_at FROM notice n JOIN pkgbase b ON b.id = n.pkgbase_id {} ORDER BY (n.severity='high') DESC, n.created_at DESC LIMIT 500", - if include_acknowledged { - "" - } else { - "WHERE n.acknowledged_at IS NULL" - } + if include_acknowledged { "" } else { "WHERE n.acknowledged_at IS NULL" } ); let mut stmt = c.prepare(&sql)?; let rows = stmt.query_map([], |r| { @@ -83,11 +78,7 @@ pub fn list_notices(db: &Db, include_acknowledged: bool) -> Result<Vec<NoticeRow pub fn acknowledge_notice(writer: &Writer, id: i64) -> Result<()> { let at = time::now(); writer.tx(move |tx| { - tx.execute( - "UPDATE notice SET acknowledged_at=?1 WHERE id=?2", - params![at, id], - )?; + tx.execute("UPDATE notice SET acknowledged_at=?1 WHERE id=?2", params![at, id])?; Ok(()) }) } - |
