Badge query for topic views

AI-generated summary

A badge query for granting a badge when a user’s topic has over 1,000 views is being discussed. not-ethan provided a SQL query example, but codergautam initially reported an error when saving it, despite it working in preview. However, codergautam later discovered the issue was due to having another badge with the same name.

Is there a badge query that gives the badge if any one of a users topic has over 1,000 views?

I found this badge query.

SELECT p.user_id, min(p.created_at) granted_at, MIN(p.id) post_id
FROM badge_posts p
JOIN topics t ON t.id = p.topic_id
WHERE category_id = (
  SELECT id FROM categories WHERE name ilike 'Technology'
) AND p.post_number = 1
AND views >= 10
and (:backfill OR ( p.id IN (:post_ids) ))
GROUP BY p.user_id

Note this is not mine. Here is the OP.

It doesn’t work sadly, works on the preview, but when i save it says “Sorry, an error has occurred.”

Wait nvm, it works, i had a nother badge wih the same name