Discourse query for total read time

I want to use Discourse Data Explorer to see total user minutes of how long my user’s are reading. Then we could modify that query to see how long the average user is reading which would also be beneficial.

Is this possible?

A very quick and easy query is…

SELECT user_id, time_read FROM user_stats ORDER BY time_read DESC

That gives you read time for all users in descending order of read time.

1 Like

Also, there are a few queries in this topic that could be a good starting place: Data explorer query to list the longest "estimated read time" topics?.


is it possible to get it by day rather than by user? like X mins read this day

I figured it out, this query gets total time spent by day:

SELECT visited_at, SUM(time_read * 60) AS total_user_secs
FROM user_visits
GROUP BY visited_at
ORDER BY visited_at

Example in my forum:

1 Like

I think time_read is already in seconds (so in minutes would be time_read /60 and in hours would be time_read /3600)

I think if you wanted to look at a graph of the average reading time per user per day within a given timeframe, the query would look something like this:

-- [params]
-- date :start_date
-- date :end_date

    ROUND(AVG(time_read/60),2)::float AS total_minutes
FROM user_visits
WHERE visited_at BETWEEN :start_date AND :end_date
GROUP BY visited_at
ORDER BY visited_at