forked from rDrama/rDrama
1
0
Fork 0

Revert "try smth on rdrama"

This reverts commit f67fc3d98a.
master
Aevann 2024-02-13 21:57:12 +02:00
parent f67fc3d98a
commit 0ef0df679a
1 changed files with 9 additions and 7 deletions

View File

@ -227,13 +227,15 @@ def searchcomments(v):
else: comments = comments.filter(Comment.author_id == author.id)
if 'exact' in criteria and 'full_text' in criteria:
regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries"
words = [Comment.body.regexp_match(regex_str)]
comments = comments.filter(*words)
elif 'q' in criteria:
words = [Comment.body.ilike('%'+x+'%') for x in criteria['q']]
comments = comments.filter(*words)
if 'q' in criteria:
tokens = map(lambda x: search_regex_1.sub('', x), criteria['q'])
tokens = filter(lambda x: len(x) > 0, tokens)
tokens = map(lambda x: search_regex_2.sub("\\'", x), tokens)
tokens = map(lambda x: x.strip(), tokens)
tokens = map(lambda x: search_regex_3.sub(' <-> ', x), tokens)
comments = comments.filter(Comment.body_ts.match(
' & '.join(tokens),
postgresql_regconfig='english'))
if 'nsfw' in criteria: comments = comments.filter(Comment.nsfw == True)