# What is the bug reporter badge?

**URL:** <https://meta.discourse.org/t/what-is-the-bug-reporter-badge/17987>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [7월 24, 2014, 8:58오전 UTC](https://meta.discourse.org/t/what-is-the-bug-reporter-badge/17987 "2014-07-24T08:58:01Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![amira.bedhiafi](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@amira.bedhiafi](https://meta.discourse.org/u/amira.bedhiafi)\
**Post date:** [9월 17, 2023, 12:33오후 UTC](https://meta.discourse.org/t/what-is-the-bug-reporter-badge/17987/34 "2023-09-17T12:33:55Z")

</div>

쿼리에 대한 개선이 될 수 있습니다:slight\_smile:

```plaintext
WITH LikeActionTypes AS (
    SELECT id 
    FROM post_action_types 
    WHERE name_key = 'like'
),

DiscourseGroup AS (
    SELECT id 
    FROM groups 
    WHERE name ILIKE 'discourse'
),

BugCategory AS (
    SELECT id 
    FROM categories 
    WHERE name ILIKE 'bug'
)

SELECT 
    p.user_id, 
    MIN(p.created_at) AS granted_at, 
    MIN(p.id) AS post_id
FROM badge_posts AS p
LEFT JOIN topics AS t ON t.id = p.topic_id
LEFT JOIN post_actions AS pa ON pa.post_id = p.id 
LEFT JOIN LikeActionTypes AS lat ON pa.post_action_type_id = lat.id
LEFT JOIN group_users AS gu ON pa.user_id = gu.user_id
LEFT JOIN DiscourseGroup AS dg ON gu.group_id = dg.id
LEFT JOIN BugCategory AS bc ON t.category_id = bc.id
WHERE p.post_number = 1
GROUP BY p.user_id;

```

---

_[View the full topic](https://meta.discourse.org/t/what-is-the-bug-reporter-badge/17987)._
