Sean_R
(Republic Wireless)
May 14, 2017, 2:36pm
1
I am wanting to add badges for Solving topics. The code is listed in the Plugin post but since I am on the hosted business version, I am unsure where to do this or even if I can without Discourses intervention. It says I can do it in the badge interface.
Here is what I am trying to add:
Badges
As it stands our plugin system has no clean way of shipping badges and removing them when a plugin is removed. While this is being solved you can add badges to your liking via the badge interface.
A badge for first accepted answer:
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
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)
For example: Helpdesk badge on Discourse Meta
A badge for 10 accepted answers
SELECT id user_id, current_timestamp granted_at
FROM users
WHERE id IN (
SELECT p1.user_id
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 p1.user_id <> t1.user_id AND
name = ‘is_accepted_answer’ AND
p1.user_id IN (
SELECT user_id
FROM posts
WHERE :backfill OR p1.id IN (:post_ids)
)
GROUP BY p1.user_id
HAVING COUNT(*) > 9
)
Tech Support badge on Discourse Meta
We disable raw badge editing by default since it is a massive security hole. I believe you are working with @zogstrip currently, he can add this badge as needed for you.
Sean_R
(Republic Wireless)
May 14, 2017, 2:40pm
4
Thanks
I will review what I want and get with him.
1 Like