From 0705ab1bf5585d7afa3b39a567f2bbfe9d403f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Tue, 5 Feb 2019 14:48:13 +0100 Subject: [PATCH] Fix missing contribution author Bug: Only if a tag and a category was present, the author was assigned. --- .../migration/neo4j/contributions.cql | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/db-migration-worker/migration/neo4j/contributions.cql b/db-migration-worker/migration/neo4j/contributions.cql index 86226b98f..0c7b18959 100644 --- a/db-migration-worker/migration/neo4j/contributions.cql +++ b/db-migration-worker/migration/neo4j/contributions.cql @@ -11,13 +11,15 @@ p.createdAt = post.createdAt.`$date`, p.updatedAt = post.updatedAt.`$date`, p.deleted = post.deleted, p.disabled = NOT post.isEnabled -WITH p, post, post.tags AS tags, post.categoryIds as categoryIds -UNWIND tags AS tag +WITH p, post +MATCH (u:User {id: post.userId}) +MERGE (u)-[:WROTE]->(p) +WITH p, post, post.categoryIds as categoryIds UNWIND categoryIds AS categoryId -MATCH (c:Category {id: categoryId}), - (u:User {id: post.userId}) +MATCH (c:Category {id: categoryId}) +MERGE (p)-[:CATEGORIZED]->(c) +WITH p, post.tags AS tags +UNWIND tags AS tag MERGE (t:Tag {id: apoc.create.uuid(), name: tag}) MERGE (p)-[:TAGGED]->(t) -MERGE (u)-[:WROTE]->(p) -MERGE (p)-[:CATEGORIZED]->(c) ;