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

Function scalar_count

src/runtime_telemetry.rs:309–335  ·  view source on GitHub ↗
(cg: &crate::tracedecay::TraceDecay, sql: &str)

Source from the content-addressed store, hash-verified

307}
308
309async fn scalar_count(cg: &crate::tracedecay::TraceDecay, sql: &str) -> Result<u64> {
310 let mut rows = cg
311 .db()
312 .conn()
313 .query(sql, ())
314 .await
315 .map_err(|e| TraceDecayError::Database {
316 message: format!("scalar query failed: {e}"),
317 operation: "scalar_count".to_string(),
318 })?;
319 let row = rows
320 .next()
321 .await
322 .map_err(|e| TraceDecayError::Database {
323 message: format!("scalar row read failed: {e}"),
324 operation: "scalar_count".to_string(),
325 })?
326 .ok_or_else(|| TraceDecayError::Database {
327 message: "no scalar row".to_string(),
328 operation: "scalar_count".to_string(),
329 })?;
330 let v: i64 = row.get(0).map_err(|e| TraceDecayError::Database {
331 message: format!("scalar decode failed: {e}"),
332 operation: "scalar_count".to_string(),
333 })?;
334 Ok(u64::try_from(v).unwrap_or(0))
335}
336
337// ---------------------------------------------------------------------------
338// Helpers

Callers 1

read_graph_countsFunction · 0.70

Calls 2

connMethod · 0.45
dbMethod · 0.45

Tested by

no test coverage detected