# Qual consulta para conceder um distintivo por curtir ou responder a um tópico específico?

**URL:** https://meta.discourse.org/t/what-query-to-award-a-badge-for-liking-or-replying-to-a-particular-topic/265926
**Category:** Data & reporting
**Tags:** sql-triggered-badge
**Created:** [23 Maio , 2023 13:40 UTC](https://meta.discourse.org/t/what-query-to-award-a-badge-for-liking-or-replying-to-a-particular-topic/265926 "2023-05-23T13:40:53Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [23 Maio , 2023 15:37 UTC](https://meta.discourse.org/t/what-query-to-award-a-badge-for-liking-or-replying-to-a-particular-topic/265926/2 "2023-05-23T15:37:44Z")

</div>

Isso deve ajudar:

> [@A badge granted when someone posts a reply in a single specified topic](https://meta.discourse.org/t/a-badge-granted-when-someone-posts-a-reply-in-a-single-specified-topic/276673/2?u=matenauta):
>
> SELECT DISTINCT ON (p.user\_id) p.user\_id, p.id post\_id, p.created\_at granted\_at FROM badge\_posts p WHERE p.topic\_id = 32 AND -- 32 is the "please introduce yourself" topic (:backfill OR p.id IN (:post\_ids) ) Triggered on “edit/create a post”.

---

_[View the full topic](https://meta.discourse.org/t/what-query-to-award-a-badge-for-liking-or-replying-to-a-particular-topic/265926)._
