Yeah the calculation doesn't work for subcategories, one reason is we don't have a recursive function to get all children and calculate the counts also we don't have a list of children category ids per category so without adding that this is difficult to achieve.
API endpoint to get online users and active topics
@Staff ACP shows total number of online users and guests at any time on the dashboard.
Similarly one can see the topics that people are reading right now. I'm curious if I can show this information in a widget on topic.tpl. is there an API endpoint that can be used to read this from?
If not where is this info saved in database?
I've not looked, but I suspect that this is calculated, not stored.
@scottalanmiller is correct, those numbers are produced on the fly based on active websocket sessions, and not stored anywhere.
However, you might be interested in https://github.com/barisusakli/nodebb-plugin-browsing-users, which brings a live-list of current users in-topic back to topic.tpl