Badge based on link stats?

Would there be any way to run a badge query on number of clicks on a link? I find that users will click a link and it will be really popular, but the topic originator never gets any likes to the post (or far less than the number of clicks to the website).

Any way to run a badge query on that?

3 Likes

That is a very good idea for a badge. Maybe we can slot that for 1.4, as we like to add at least one useful (encourages “good” behavior) badge each release.

3 Likes

https://meta.discourse.org/badges/124/popular-link

SQL

select l.user_id, post_id, min(l.created_at) granted_at
from topic_links l
join posts p on p.id = post_id and p.deleted_at IS NULL
join topics t on t.id = p.topic_id and t.deleted_at IS NULL and t.archetype <> 'private_message'
where not internal and clicks >= 50
group by l.user_id, l.post_id

@codinghorror I don’t mind adding this in for current release … seems pretty simple, your call

2 Likes

It is fine to wait, no need to rush badges.

1 Like

If the badge is bronze, nobody’s ever going to receive a notification for that; the granted_at will be too old. You’re going to have to use row_number() to get the correct date for the badge.

1 Like

These badges are now officiel :cow2:

https://github.com/discourse/discourse/commit/d96531b1635b461b423a6a36a20299cf72ef0ed1

4 Likes