# New extensibility sub-category: Badge Queries

**URL:** https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645
**Category:** Site feedback
**Created:** [8월 28, 2015, 2:20오후 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645 "2015-08-28T14:20:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [8월 28, 2015, 2:20오후 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645/1 "2015-08-28T14:20:11Z")

</div>

I’d like to propose the creation of a new sub-category for Extensibility, called “Badge Queries”.

This thread in particular is filled to the rim with excellent query snippets (major props to @PJH and @riking):

> [@\[Superseded\] What cool badge queries have you come up with?](https://meta.discourse.org/t/what-cool-badge-queries-have-you-come-up-with/18978):
>
> warning Enabling Badge SQL entails security and performance risks so it is not available by default. For more information, see: [Enable Badge SQL](https://meta.discourse.org/t/badge-sql-can-no-longer-be-edited-by-default/47894) This topic became too long to be easily searched and has been broken down into separate topics. If you have any questions about how to write a badge query, or have one to share, please start a new topic in the #data & reporting category and tag it with the #sql-triggered-badge tag. +1 More ideas: [Some common badge queries](https://meta.discourse.org/t/some-common-badge-queries-idea/31859)

There’s also this:

> [@Some common badge queries](https://meta.discourse.org/t/some-common-badge-queries-idea/31859):
>
> warning Enabling Badge SQL entails security and performance risks so it is not available by default. For more information, see: [Enable Badge SQL](https://meta.discourse.org/t/badge-sql-can-no-longer-be-edited-by-default/47894) Here are some common badge queries which you can use to create your own awesome badge! Grant a badge if user has created at least one topic in the “foo”\* category \*(“foo” is the category name, not the category slug) 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 cate…

And a couple other How-tos spread around.

This info ought to be easily searchable and maintainable. That could be achieved with a dedicated sub-forum, where each query snippet could have its own dedicated topic. Would also be a good use case for the new Post Templates, since each new topic should follow a template that goes something like this:

```plaintext
(Use the topic title to describe the most basic function of your query.)

**Suggested title:** {What would you call this query?}

{Please describe what this query does and how that might be useful.}

'''sql
Insert your query here
'''

```

In the future it might be worthwhile to keep the snippets in individual files collected in a GitHub repository, and display them in their respective topics via the link embeds. That would facilitate the creation of a more easily searchable interface (example: [hookr.io](http://hookr.io/)).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [8월 28, 2015, 9:58오후 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645/2 "2015-08-28T21:58:27Z")

</div>

To be honest, I am not a fan of the whole badge queries genre; the good ones we should just ship in each version of Discourse, and the bad ones can cripple performance on your site with horrendous or broken SQL.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [8월 28, 2015, 10:50오후 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645/3 "2015-08-28T22:50:59Z")

</div>

> [@codinghorror](#):
>
> the bad ones can cripple performance on your site with horrendous or broken SQL.

Yeah, that’s another reason why I wanted these queries to be treated as more than a “cool tip”. Every custom query merits its own discussion and success/failure reports.

Including many of these queries in Discourse core would be great, but surely there will still be a few niche ones left out that ought to have space of their own.

A special tag or variety of the Solved plugin could be nice here too, i.e. to mark queries as “Tested” (or “Reviewed”, or “Safe”).

There could also be a “Query Author” badge.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [8월 29, 2015, 6:17오전 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645/4 "2015-08-29T06:17:55Z")

</div>

Now that the badge analyser is visible again could we not have a sticky in that category explaining how to use costs to determine whether a query will impact performance?

I’ve found out the hard way what happens when bad queries aren’t resolved prior to other operations. Rebuilding with a test badge enabled did some fairly horrible things.

---

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [8월 30, 2015, 1:05오후 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645/5 "2015-08-30T13:05:42Z")

</div>

Community are different, and different are goals and badges.  
Take a look to my badges:

> **[NethServer Community](https://community.nethserver.org/badges)**
>
> Multi-node application platform for your Hybrid Cloud

And to this discussion:

> [@Define additional badge types](https://meta.discourse.org/t/define-additional-badge-types/31781):
>
> Continuing the discussion from [Badges feedback](https://meta.discourse.org/t/badges-feedback/13789/11): Let me resurrect this thread, I need additional types/colours like Platinum, Diamond, ecc.. Groups are not enough for my purpose. Is there any chance?

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8월 14, 2023, 8:46오후 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645/6 "2023-08-14T20:46:45Z")

</div>

이제는 #data-reporting 카테고리에서 #sql-triggered-badge 태그를 사용하여 이 항목들을 찾을 수 있습니다
