From 932a593cfa3cbefff6aee3f0b4cdbfd2f601749a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 21 Jan 2019 23:38:48 +0100 Subject: [PATCH] Import follows --- neo4j/import/follows.cql | 4 ++++ neo4j/import/import.sh | 2 +- neo4j/import/todo | 10 ---------- 3 files changed, 5 insertions(+), 11 deletions(-) create mode 100644 neo4j/import/follows.cql diff --git a/neo4j/import/follows.cql b/neo4j/import/follows.cql new file mode 100644 index 000000000..0dad6a435 --- /dev/null +++ b/neo4j/import/follows.cql @@ -0,0 +1,4 @@ +CALL apoc.load.json('file:/mongo-export/follows.json') YIELD value as follow +MATCH (u1:User {id: follow.userId}), (u2:User {id: follow.foreignId}) +MERGE (u1)-[:FOLLOWS]->(u2) +; diff --git a/neo4j/import/import.sh b/neo4j/import/import.sh index 86224d240..d712dea0a 100755 --- a/neo4j/import/import.sh +++ b/neo4j/import/import.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" echo "MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r;" | cypher-shell -for collection in "badges" "categories" "users" "contributions" "comments" +for collection in "badges" "categories" "users" "follows" "contributions" "comments" do echo "Import ${collection}..." && cypher-shell < $SCRIPT_DIRECTORY/$collection.cql done diff --git a/neo4j/import/todo b/neo4j/import/todo index 8ee1bb83a..73eae2396 100644 --- a/neo4j/import/todo +++ b/neo4j/import/todo @@ -1,14 +1,4 @@ -CALL apoc.load.json('file:/mongo-export/badges.json') YIELD value as badge -MERGE(b:Badge {id: badge._id["$oid"]}) -ON CREATE SET b.key = badge.key, - b.type = badge.type, - b.icon = badge.image.path, - b.status = badge.status -CALL apoc.load.json('file:/mongo-export/follows.json') YIELD value as follow -MATCH (u1:User {id: follow.userId}), - (u2:User {id: follow.foreignId}) -MERGE (u1)-[:FOLLOWS]->(u2) CALL apoc.load.json('file:/mongo-export/shouts.json') YIELD value as shout MATCH (u:User {id: shout.userId}),