Yeah so the WITH query looks to maybe be the problem, as it is pulling every user regardless of the category the topic is in. For instance I have one user that it’s returning 9 posts but they are in those protected topic IDs (43, 47, 48, 49, 59):
r as (
SELECT p.user_id, count(p.id) as replies
FROM posts p, t, pr
WHERE p.post_type = 1 AND
p.post_number > 1 AND
(p.created_at > t.start and
p.created_at < t.end)
and p.user_id not in ('-1', '-2')
AND pr.user_id = p.user_id
AND p.topic_id not in ('4','24','26','32','33','34','35','36','37','38','39','40','43','47','48','49','50')
GROUP BY p.user_id),