Grant a badge for anyone that posts in a certain category


(Steven) #1

I am looking for a way to grant a user a badge if they create a new topic in a certain category.

This badge should be awarded each time they create a new topic. (awarded multiple times)
This badge should not be awarded if they are replying to a topic. (awarded for new posts only)

How would I do this?


(Michael Downey) #2

I believe what you’re asking for can be done by using the “bug reporter” query and just removing the second “JOIN” statement:

This makes your query something like:

SELECT p.user_id, min(p.created_at) granted_at, MIN(p.id) post_id
FROM badge_posts p
JOIN topics t ON t.id = p.topic_id
WHERE category_id = (
  SELECT id FROM categories WHERE name ilike 'Your Category'
) AND p.post_number = 1
GROUP BY p.user_id

See also this topic for other ideas:


New badge added: Scribe
(system) #4

(Sam Saffron) #5