Skip to content

Instantly share code, notes, and snippets.

@johnymontana
Last active December 26, 2018 23:57
Show Gist options
  • Save johnymontana/0a273aef7db0dd0bf1b22fd65e2cc914 to your computer and use it in GitHub Desktop.
Save johnymontana/0a273aef7db0dd0bf1b22fd65e2cc914 to your computer and use it in GitHub Desktop.
// load repositories
UNWIND ["repositories_000001.json", "repositories_000002.json"] AS file
CALL apoc.load.json($baseURL + file) YIELD value
// only import public repos
WITH value AS repo WHERE repo.private = false
MERGE (r:Repository {url: repo.url})
SET r += repo {.name, .description, .website, created_at: DateTime(repo.created_at)}
MERGE (u:User {url: repo.owner})
MERGE (r)<-[:OWNS]-(u)
FOREACH (collab IN repo.collaborators |
MERGE (c:User {url: collab.user})
MERGE (c)-[cr:COLLABORATES]->(r)
SET cr.permission = collab.permission
)
FOREACH (webhook IN repo.webhooks |
MERGE (w:Webhook {url: webhook.payload_url})
MERGE (r)-[:HAS_WEBHOOK]->(w)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment