Rename variables

This commit is contained in:
Wolfgang Huß 2019-09-04 15:38:28 +02:00
parent 0a86cb6c4d
commit 0df086e07f
2 changed files with 7 additions and 6 deletions

View File

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

View File

@ -215,8 +215,9 @@ export default {
},
sanitizeQuery(query) {
if (this.suggestionType === HASHTAG) {
const regexMatchAllNonUnicodeOrDigits = build('[^\\pL0-9]')
query = replace(query, regexMatchAllNonUnicodeOrDigits, '', 'all')
// remove all non unicode letters and non digits
const regexMatchAllNonUnicodeLettersOrDigits = build('[^\\pL0-9]')
query = replace(query, regexMatchAllNonUnicodeLettersOrDigits, '', 'all')
// if the query is only made of digits, make it empty
return query.replace(/[0-9]/gm, '') === '' ? '' : query
}