I tried this for users who have created a new Topic in a specific Category that satisfied some conditions.
SELECT DISTINCT ON (p.user_id) p.user_id, p.id post_id, p.created_at granted_at
FROM posts p
INNER JOIN topics t
ON p.topic_id=t.id
WHERE t.category_id = 99 AND p.post_number=1 AND <conditions here> AND
(:backfill OR p.id IN (:post_ids) )