How do I make my own badge query?

AI-generated summary

In the Data & reporting category, keith1 sought guidance on where to input custom SQL queries for creating badges, noting that existing resources did not specify the location for code like SELECT user_id.... Pad_Pors initially shared general links regarding badge topics and manual grants. However, keith1 clarified that the specific question concerned the administrative interface or file path for these queries, as they were unsure if editing was done via an admin section or external files. dax resolved the confusion by explaining that SQL editing is disabled by default on recent versions. They directed keith1 to a meta topic explaining how to enable this feature, after which a new SQL field becomes available at /admin/badges/new. keith1 confirmed that this information answered their question.

I’m feeling quite silly for having to ask, but I’m finding tons of great resources for making my own badges, but I can’t figure out where exactly to put all of these badge queries. Can someone just point me in the right direction?

Thanks!
Keith

there is a topic describing other badges:

the faq topic for badge (which may not be what you want):

creating badge:

Yes, like I said, I’ve found loads of great resources on here for customizing my own badges, etc (I guess I should have linked them to prevent this answer), but on a very basic level, I can’t find any information of where to put the queries. Let me be more specific:

SELECT user_id, 0 post_id, current_timestamp granted_at 
FROM badge_posts  
WHERE (:backfill OR user_id IN (:user_ids) OR 0 NOT IN (:post_ids) )
GROUP BY user_id 
HAVING count(*) > 1000

Where does this code belong? Is there an admin section for badge query modifications that I’m not finding, or is this offline/external file editing, in which case, can you just point me to where in the discourse directories these live? None of the topics on here about badge creation actually mention this bit, so I’m assuming it’s something entirely obvious that I’m missing.

Are you on latest?

If you are, read this before

After you enabled it, you will find a new SQL field on /admin/badges/new

Aha! That was the part I was missing. Thank you for connecting those dots!