Locked query field for system badges

AI-generated summary

In a support discussion titled ‘Locked query field for system badges’, iidbae, a new member, seeks help modifying a SQL badge query to award a Gold badge after 25 successful invitations, by changing HAVING COUNT(*) >= 5 to >= 25. They initially struggle with copying the code and understanding SQL, referencing a similar topic here. cpradio directs them to instructions for enabling SQL badge queries here. iidbae confirms they enabled SQL but the field remains locked, suspecting it’s for security. They also mention exploring GitHub without success. simon provides the direct link to the badge query SQL file: badge_queries.rb. iidbae thanks Simon, admitting they used the wrong search terms on GitHub, and although they found the SQL, they remain confused — planning to open a new topic for further questions. The discussion reflects a beginner’s effort to customize badge logic, with community support guiding them toward the right resources.

This is my first topic after become a member here since 222 days ago.

  1. How to copy-paste this code?

  2. I want to give a badge for 25 successful invitations. So, I only need change the value HAVING COUNT (*) >= 5 into HAVING COUNT (*) >= 25, and give a Gold badge type too. Am I right?

I found similar topic "Promoter" Badge broken? but I just want to confirm, because I am not a really understand in coding.

Sorry for my stupid question.

Here are the steps for enabling the SQL Badge Queries

Thank you Cpradio, yes I have enabled the SQL within 3 days, but its still locked.
I believe its for security purpose.
I tried to explore the Github too, but still does not know how to find the code line.

You can find the badge query SQL here: discourse/lib/badge_queries.rb at main · discourse/discourse · GitHub

Thank you very much Simon.
I put wrong keyword in searching the code in the repository.
After I found the sql query, I still confuse.

I want to open another support topic, to make another question relating to this.
Thank you.