-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add followers count cache for future queries
- Loading branch information
Showing
7 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX FOR (u:User) ON (u.follower_count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Queries Directory | ||
|
||
This directory contains Neo4j Cypher queries intended for manual database changes, data inspection, and analysis. These queries can be used to make one-off updates, verify data integrity, and generate insights for reporting. As the project evolves, this collection will grow and be used for ongoing database analysis and reporting. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Looks for users with more than 100 followers that have too many followers with very few followees | ||
|
||
MATCH (suspect:User)-[f:FOLLOWS]->(target:User) | ||
WITH target, COUNT(DISTINCT suspect) AS num_followers | ||
WHERE num_followers > 100 | ||
WITH target, num_followers | ||
ORDER BY num_followers DESC | ||
LIMIT 10 | ||
MATCH (suspect:User)-[f:FOLLOWS]->(target:User) | ||
MATCH (suspect)-[:FOLLOWS]->(others:User) | ||
WITH target, num_followers, suspect, COUNT(DISTINCT others) AS num_followees | ||
WHERE num_followees < 3 | ||
WITH target, num_followers, COUNT(DISTINCT suspect) AS num_suspects | ||
ORDER BY num_suspects DESC | ||
RETURN target, num_followers, num_suspects | ||
LIMIT 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This query selects up to 1000 users with a null follower count, counts their | ||
// followers, updates the follower count, and returns the user’s public key | ||
// along with the updated count. | ||
|
||
MATCH (user:User) | ||
WHERE user.follower_count IS NULL | ||
WITH user | ||
LIMIT 1000 | ||
OPTIONAL MATCH (follower:User)-[:FOLLOWS]->(user) | ||
WITH user, COUNT(follower) AS follower_count | ||
SET user.follower_count = follower_count | ||
RETURN user.pubkey, user.follower_count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters