(cg: &crate::tracedecay::TraceDecay)
| 273 | } |
| 274 | |
| 275 | async fn read_source_total_bytes(cg: &crate::tracedecay::TraceDecay) -> Result<u64> { |
| 276 | let mut rows = cg |
| 277 | .db() |
| 278 | .conn() |
| 279 | .query("SELECT COALESCE(SUM(size), 0) FROM files", ()) |
| 280 | .await |
| 281 | .map_err(|e| TraceDecayError::Database { |
| 282 | message: format!("failed to sum source bytes: {e}"), |
| 283 | operation: "read_source_total_bytes".to_string(), |
| 284 | })?; |
| 285 | let row = rows |
| 286 | .next() |
| 287 | .await |
| 288 | .map_err(|e| TraceDecayError::Database { |
| 289 | message: format!("failed to read source-sum row: {e}"), |
| 290 | operation: "read_source_total_bytes".to_string(), |
| 291 | })? |
| 292 | .ok_or_else(|| TraceDecayError::Database { |
| 293 | message: "no source-sum row returned".to_string(), |
| 294 | operation: "read_source_total_bytes".to_string(), |
| 295 | })?; |
| 296 | let v: i64 = row.get(0).map_err(|e| TraceDecayError::Database { |
| 297 | message: format!("failed to decode source-sum: {e}"), |
| 298 | operation: "read_source_total_bytes".to_string(), |
| 299 | })?; |
| 300 | Ok(u64::try_from(v).unwrap_or(0)) |
| 301 | } |
| 302 | |
| 303 | async fn read_graph_counts(cg: &crate::tracedecay::TraceDecay) -> Result<(u64, u64)> { |
| 304 | let nodes = scalar_count(cg, "SELECT COUNT(*) FROM nodes").await?; |
no test coverage detected