Badge for reading a topic?

AI-generated summary

The discussion explores creating a SQL-triggered badge for users who read a specific topic for at least 5 minutes. barto_95 asks if it’s possible to award a badge based on reading duration, not just opening the topic. JammyDodger provides a SQL query using topic_users to check total_msecs_viewed, but notes that the query must not target posts if it returns a post_id error. barto_95 encounters this error and resolves it by adjusting the badge setup, as shown in JammyDodger’s image. After fixing the query, barto_95 asks about the best trigger, and JammyDodger recommends ‘Update Daily’ since it captures changes in topic_users read time. barto_95 confirms the badge is assigned, though inconsistently every 22 hours.

It’s possible to add a badge if user read the specific topic/subject of forum ? and not just opened the topic but he read ~5minutes to be sure the user read the info ?

I think this should be possible with something like:

SELECT user_id, CURRENT_TIMESTAMP AS granted_at
FROM topic_users
WHERE topic_id = 281534
  AND total_msecs_viewed/60000 >= 5 -- min number of minutes viewed

I test and received this error:

Error : Contract violation: Query targets posts, but does not return a 'post_id' column

I think that’s because you’ve ticked the ‘Query targets posts’ box. If you set it up to more like this it should work fine:

Ok thank’s no error now

what do you recommend as a trigger ?

I think it would have to be Update Daily. I don’t think any of the other triggers would catch a change in the topic_users read time stat.

Ok I configured this first for test

this happens every 22 hours it seems to me regarding the assignment of badges