MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / build_native_graph_stats_sql

Function build_native_graph_stats_sql

nodedb-client/src/native/client/graph.rs:129–139  ·  view source on GitHub ↗

Build the SQL for `SHOW GRAPH STATS` for the native protocol. Collection and `as_of` are both optional; when absent the corresponding clause is omitted entirely.

(collection: Option<&str>, as_of: Option<i64>)

Source from the content-addressed store, hash-verified

127/// and `as_of` are both optional; when absent the corresponding clause is
128/// omitted entirely.
129pub(crate) fn build_native_graph_stats_sql(collection: Option<&str>, as_of: Option<i64>) -> String {
130 let mut sql = "SHOW GRAPH STATS".to_string();
131 if let Some(c) = collection {
132 sql.push(' ');
133 sql.push_str(&quote_string_literal(c));
134 }
135 if let Some(ms) = as_of {
136 sql.push_str(&format!(" AS OF SYSTEM TIME {ms}"));
137 }
138 sql
139}
140
141/// Parse a multi-row response from `SHOW GRAPH STATS` into a vec of
142/// `GraphStats`. Empty rows produce an empty vec. Column-shape mismatches

Callers 4

graph_stats_implMethod · 0.85
build_sql_tenant_wideFunction · 0.85
build_sql_as_ofFunction · 0.85

Calls 3

quote_string_literalFunction · 0.85
to_stringMethod · 0.80
pushMethod · 0.45

Tested by 3

build_sql_tenant_wideFunction · 0.68
build_sql_as_ofFunction · 0.68