Skip to content

Commit

Permalink
feat: filtering out graph nodes without any mentions or influences
Browse files Browse the repository at this point in the history
  • Loading branch information
112batuhan committed Nov 28, 2024
1 parent e966a62 commit 9db6ba2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/database/graph_vizualizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct GraphUser {
avatar_url: String,
mentions: u32,
username: String,
influenced_by: u32,
}

#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Clone, Debug)]
Expand All @@ -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?
Expand All @@ -42,7 +47,7 @@ impl DatabaseClient {
pub async fn get_influences_for_graph(&self) -> Result<Vec<GraphInfluence>, AppError> {
let graph_influences: Vec<GraphInfluence> = 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)
Expand Down

0 comments on commit 9db6ba2

Please sign in to comment.