From 9db6ba2d3e097a5a949d0690a50b423b4f777fc7 Mon Sep 17 00:00:00 2001 From: 112batuhan Date: Thu, 28 Nov 2024 20:07:52 +0300 Subject: [PATCH] feat: filtering out graph nodes without any mentions or influences --- src/database/graph_vizualizer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/database/graph_vizualizer.rs b/src/database/graph_vizualizer.rs index 8803f28..941db3e 100644 --- a/src/database/graph_vizualizer.rs +++ b/src/database/graph_vizualizer.rs @@ -11,6 +11,7 @@ pub struct GraphUser { avatar_url: String, mentions: u32, username: String, + influenced_by: u32, } #[derive(Serialize, Deserialize, JsonSchema, PartialEq, Clone, Debug)] @@ -28,10 +29,14 @@ impl DatabaseClient { " SELECT meta::id(id) AS id, - count(<-influenced_by) AS mentions, + count(<-influenced_by) AS mentions, + count(->influenced_by) AS influenced_by, avatar_url, username FROM user + WHERE + count(<-influenced_by) > 0 + OR count(->influenced_by) > 0; ", ) .await? @@ -42,7 +47,7 @@ impl DatabaseClient { pub async fn get_influences_for_graph(&self) -> Result, AppError> { let graph_influences: Vec = self .db - .query("SELECT meta::id(in) AS source, meta::id(out), influence_type AS target FROM influenced_by;") + .query("SELECT meta::id(in) AS source, meta::id(out) AS target, influence_type FROM influenced_by;") .await? .take(0)?; Ok(graph_influences)