How can I add new badges?


(smota) #1

Hi expert, I learning as fast as I can about discourse,
Now I would like to undarstaind how to add those code.

Where do i have to insert this code.

SELECT p.user_id, p.id post_id, p.updated_at granted_at
FROM badge_posts p
WHERE p.post_number > 1 AND
p.id IN (
SELECT post_id FROM (
SELECT pc.post_id, row_number()
OVER (PARTITION BY p1.user_id ORDER BY pc.created_at) as rnum
FROM post_custom_fields pc
JOIN badge_posts p1 ON p1.id = pc.post_id
JOIN topics t1 ON p1.topic_id = t1.id
WHERE name = ‘is_accepted_answer’ AND
value IS NOT NULL AND
p1.user_id <> t1.user_id AND
(
:backfill OR
p1.user_id IN (
select user_id from posts where p1.id IN (:post_ids)
)
)
) X WHERE rnum = 1)


(cpradio) #2

First start with

Second, install the data explorer plugin. Copy that query and insert it into the data explorer plugin.


(Daniela) #3

Enable the queries for badges following this:

After that you can add the SQL query when you create new badges (/admin/badges)


(Daniela) #4

It’s a query for the badge first accepted answer, not for Data Explorer :wink:


(Jay Pfaffman) #5

What is it that you are actually trying to accomplish? It’s not clear that the solution you proposed solves the problem you are trying to solve


(smota) #6

I just trying to add those new badges. I had added the answer mark’s plugin.


(Daniela) #7

You can’t add the SQL queries for badges until you enable it on your server. Read my previous messages :grinning: