# Contest participant get a Badge

**URL:** <https://meta.discourse.org/t/contest-participant-get-a-badge/32769>\
**Category:** Product Support\
**Created:** [1. September 2015 um 08:29 UTC](https://meta.discourse.org/t/contest-participant-get-a-badge/32769 "2015-09-01T08:29:32Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Imperator](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/imperator/32/45089_2.png) [@Imperator](https://meta.discourse.org/u/Imperator)\
**Post date:** [1. September 2015 um 08:29 UTC](https://meta.discourse.org/t/contest-participant-get-a-badge/32769/1 "2015-09-01T08:29:32Z")

</div>

Hi,

I make a Contest and will that the participant gain a Badge for participation.  
The participant must create a post on a certain topic in a certain categorie.

Also i search here for the something and i found this…

> [@What is the bug reporter badge?](https://meta.discourse.org/t/what-is-this-bug-reporter-badge/17987):
>
> You may or may have not noticed this new badge: [https://meta.discourse.org/badges/114/bug-reporter](https://meta.discourse.org/badges/114/bug-reporter) What I find super exciting about it is that there are zero plugins needed, I crafted it using our badges UI. Not only does it grant the badge daily, it will also grant it after one of the team “likes” a bug. It runs the following badge query: 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 JOIN post\_actions pa ON pa.post\_id…

I only must change a little bit the code…

```
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
JOIN post_actions pa ON pa.post_id = p.id AND 
      post_action_type_id = (
                SELECT id FROM post_action_types WHERE name_key = 'like'
       ) AND 
       pa.user_id IN (
           SELECT gu.user_id
           FROM group_users gu
           WHERE gu.user_id = ( SELECT id FROM users WHERE username ilike 'Username' ) 
       )
WHERE category_id = (
  SELECT id FROM categories WHERE name ilike 'Casual Contest'
) GROUP BY p.user_id

```

with that i have only to Like all post of the participant.  
And it Work!

**BUT…**

for testing that that work i have like a post and it work. But if i Disslike that post the post stays in that query.

Or have a better Idea for that?  
Every month is a new Contest and every contest the participant have to post to a other certain topic.

regards,  
Imperator

---

_[View the full topic](https://meta.discourse.org/t/contest-participant-get-a-badge/32769)._
