Read time & badgers on custom pages

We are running some custom documentation pages at custom routes.
I’d love to know how to hook into Discourse’s built-in read-time metrics on these pages. Ideally I’d like to solve this usecase:

Grant a ‘Bookworm badge’ to anyone who has spent at least 4 hours reading pages under /documentation

Can anyone point us in the right direction?
Thanks!

2 Likes

I can’t wait to see what the badger looks like!

7 Likes

Do you know if entering the custom route adds an entry to the post_timings table? If so, you could get the read times from there.

No, seems it only contains entries with a valid topic_id
Perhaps we could extend this somehow, but that feels like adding even more logic.

This does raise an interesting question though… does discourse not count reading things like the homepage / categories overview etc?

Think I’ll keep this typo for now :smiley:

2 Likes

5 Likes

As far as I know, we can easily store things per user in the pluginstore, think that would be the most viable approach for this. Just a key-value pair with the static page’s slug and the total read time for this user.