Grant Badge when user visits link

If it’s a specific link shared in a specific post, I think this one would do it:

SELECT DISTINCT tlc.user_id, MIN(tlc.created_at) granted_at
FROM badge_posts p
  LEFT JOIN topic_links tl ON tl.post_id = p.id
  LEFT JOIN topic_link_clicks tlc ON tlc.topic_link_id = tl.id
WHERE tl.post_id = 1246
  AND tl.url = 'https://meta.discourse.org/'
  AND tlc.user_id IS NOT NULL
GROUP BY tlc.user_id

You’d need to grab the post_id of your specific post from its post json (or run a look up through the data explorer)

2 Likes