# New extensibility sub-category: Badge Queries

**URL:** <https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645>\
**Category:** Site feedback\
**Created:** [2015 年8 月 28 日 14:20 UTC](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645 "2015-08-28T14:20:11Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![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)\
发布日期： [2015 年8 月 28 日 14: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/)).

---

_[View the full topic](https://meta.discourse.org/t/new-extensibility-sub-category-badge-queries/32645)._
