MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / read_source_total_bytes

Function read_source_total_bytes

src/runtime_telemetry.rs:275–301  ·  view source on GitHub ↗
(cg: &crate::tracedecay::TraceDecay)

Source from the content-addressed store, hash-verified

273}
274
275async 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
303async fn read_graph_counts(cg: &crate::tracedecay::TraceDecay) -> Result<(u64, u64)> {
304 let nodes = scalar_count(cg, "SELECT COUNT(*) FROM nodes").await?;

Callers 1

sample_databaseFunction · 0.85

Calls 2

connMethod · 0.45
dbMethod · 0.45

Tested by

no test coverage detected