Read time & badgers on custom pages


(Bas van Leeuwen) #1

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

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


(Simon Cossar) #3

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.


(Bas van Leeuwen) #4

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?


(Bas van Leeuwen) #5

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


(Colin Marshall) #6


(Bas van Leeuwen) #7

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.