fix(analytics): replace regexp_split_to_table with UNNEST+STRING_TO_ARRAY and fix regex escapes

This commit is contained in:
MythEclipse
2026-06-03 19:55:43 +07:00
parent 4e12394168
commit cbee35c348
@@ -323,15 +323,15 @@ export class AnalyticsRepository {
LOWER(TRIM(BOTH '.,!?;:\"()[]{}' FROM word)) AS word,
ai_moderation_score
FROM messages,
LATERAL regexp_split_to_table(content, E'\\\\s+') AS word
LATERAL UNNEST(STRING_TO_ARRAY(content, ' ')) AS word
${filter.where}
AND content IS NOT NULL
AND content != ''
AND LENGTH(TRIM(BOTH '.,!?;:\"()[]{}' FROM word)) >= 3
AND word !~ '^<.+:\\d+>$'
AND word !~ '^https?://'
AND word !~ '^discord\\.(gg|app|com)'
AND word !~ '^cdn\\.discord'
AND word !~ '^discord\.(gg|app|com)'
AND word !~ '^cdn\.discord'
)
SELECT
word AS topic,