Revert changes from commit #ca88d1a

- we need to remove the whitespaces first, then check if there are still illegitimate characters in the hashtag before removing them
- this is to maintain the maximum number of hashtags imported from the legacy database as possible
This commit is contained in:
Matt Rider 2019-09-02 15:07:22 +02:00
parent d1309d2b8f
commit 62e7aee4a3

View File

@ -148,9 +148,10 @@ MATCH (c:Category {id: categoryId})
MERGE (p)-[:CATEGORIZED]->(c)
WITH p, post.tags AS tags
UNWIND tags AS tag
CALL apoc.when(tag =~ '^((\\p{L}+[\\p{L}0-9]*)|([0-9]+\\p{L}+[\\p{L}0-9]*))$', 'RETURN tag', '', {tag: tag})
WITH apoc.text.replace(tag, '[^\\p{L}0-9]', '') as tagNoSpacesAllowed
CALL apoc.when(tagNoSpacesAllowed =~ '^((\\p{L}+[\\p{L}0-9]*)|([0-9]+\\p{L}+[\\p{L}0-9]*))$', 'RETURN tagNoSpacesAllowed', '', {tagNoSpacesAllowed: tagNoSpacesAllowed})
YIELD value as validated
WHERE validated.tag IS NOT NULL
MERGE (t:Tag { id: validated.tag, disabled: false, deleted: false })
WHERE validated.tagNoSpacesAllowed IS NOT NULL
MERGE (t:Tag { id: validated.tagNoSpacesAllowed, disabled: false, deleted: false })
MERGE (p)-[:TAGGED]->(t)
;