Could this one be based on the post_action for ‘Notify User’?
Something like:
SELECT pa.user_id, current_timestamp AS granted_at
FROM post_actions pa
JOIN posts p ON p.id = pa.related_post_id
WHERE pa.post_action_type_id = 6
AND p.like_count >= 1
AND (:backfill OR p.user_id IN (:user_ids))
GROUP BY pa.user_id
HAVING COUNT(*) >= 1
Actually, I think that links in the post that the flag was based on, not the PM. It may need a small tweak.
A quick change to the join to make p.id = pa.related_post_id does the job, I think. ![]()
I think the ‘HAVING` is only needed for if you want to grant a Silver and Gold version of more than just one.