Consolidate backend scanner status, paging, and query-param duplication

Add ActiveStatusCell/PassiveStatusCell wrappers in the scanners common
module so the five per-scanner status.rs files reduce to a single static;
replace parse_parameter_bool/int/string with one generic parse_parameter
over FromStr; extract the shared LIMIT/OFFSET paging clause into
db::apply_paging; and drop a no-op for-loop in the ARP sender.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-06 09:03:00 -04:00
co-authored by Claude Opus 4.8
parent c022e672d1
commit 8749ff33c1
27 changed files with 189 additions and 260 deletions
+20
View File
@@ -41,6 +41,26 @@ pub fn get_db_connection() -> PooledConnection<SqliteConnectionManager> {
}
}
// Appends the shared `LIMIT ? OFFSET ?` paging clause (and its bound parameters) to a list query
// when both an offset and a limit are supplied. Used by the list endpoints (devices, notifications,
// device_events) so they page identically.
pub fn apply_paging(
sql: &mut String,
params: &mut Vec<rusqlite::types::Value>,
page_offset: Option<i64>,
page_limit: Option<i64>,
) {
if let (Some(page_offset), Some(page_limit)) = (page_offset, page_limit) {
debug!(
"Adding paging to list with offset={} and limit={}",
page_offset, page_limit
);
sql.push_str(" LIMIT ? OFFSET ?");
params.push(page_limit.into());
params.push(page_offset.into());
}
}
pub async fn init_db() -> Result<(), DbError> {
let mut initialised = INITIALISED.lock().await;
if *initialised {