Skip to content

Instantly share code, notes, and snippets.

@ikwattro
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikwattro/9bb03a93f10f4ee49c57 to your computer and use it in GitHub Desktop.
Save ikwattro/9bb03a93f10f4ee49c57 to your computer and use it in GitHub Desktop.
neo4j-github-recommendation
MATCH (u:User)-[r:DO]->()
RETURN u.name, count(r) as events
ORDER BY events DESC
LIMIT 1
---------
u.name	events
imclab	273
Returned 1 row in 2755 ms
MATCH p=(u:User)-[:DO]-(e:PullRequestEvent)-->
(pr:PullRequest {state:'merged'})-[:PR_ON_REPO]->
(r:Repository)<-[:PR_ON_REPO]-(pr2:PullRequest {state:'merged'})
--(e2:PullRequestEvent)<-[:DO]-(u2:User)
WHERE NOT u = u2
WITH nodes(p) as coll
WITH head(coll) as st, last(coll) as end
MERGE (st)-[r:HAVE_WORKED_ON_SAME_REPO]-(end)
ON MATCH SET r.w = (r.w) + 1
ON CREATE SET r.w = 1
---------
Created 1122 relationships, returned 0 rows in 2334 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment