So, I want to give a badge to a member who has successful invited 25 people.
Just like the existing badge, the Campaigner (3 people) or Champion (5 people).
The reward is only a badge without raising the Trust Level.
The concept is similar with the SQL Badge Query in “A badge for 10 accepted answers” Discourse Solved Only need changes the number.
Hi Andrew, thank you for your simple and easy explanation.
I am really appreciate that.
I just want to confirm if the below query is right:
SELECT u.id user_id, current_timestamp granted_at
FROM users u
WHERE u.id IN (
SELECT invited_by_id
FROM invites i
JOIN users u2 ON u2.id = i.user_id
WHERE i.deleted_at IS NULL AND u2.active AND u2.trust_level >= 2 AND u2.silenced_till IS NULL
GROUP BY invited_by_id
HAVING COUNT(*) >= 25
) AND u.active AND u.silenced_till IS NULL AND u.id > 0 AND
(:backfill OR u.id IN (:user_ids) )
So the query will automatically give a badge to a member who has successful invite 25 people when the TL is 2. Am I right?