Why are stats not updated in real time?

Hey there, we’re building a front-end around the discourse API, and we’ve encountered a weird behaviour regarding stats not updating in real-time in a couple of places.

  • For one, when fetching /directory_items.json?period=all&order=likes_given, we’ve noticed that if a user gives a couple of likes, the stats are not updated until quite some time passes.
  • The other place we’ve noticed this, is when fetching the user summary stats by fetching /u/<user>/summary.json, stats seem to not be updated correctly or at least not in real-time

We’re using bitnamis docker image to run Discourse, we’re unsure if this issue might be related to this particular image, or if this is an expected behaviour of the discourse API itself.

The docker image uses something called sideqik, which we thought could be the culprit of the issue. We’ve tried to run what seemed like the correct task (Jobs::DashboardStats) to update the stats, but without any luck. Stats do not update even after triggering the scheduled tasks. Is there any other task related to this, or are we not looking in the correct place?

Regards,
Manolo

All good platforms distinguish between things that absolutely must be up-to-date and those things that can probably wait and save resources.

Directory Items appears to update every hour. This means that it is much cheaper to show the same result to each individual user rather than have it calculated on demand each time a user tries to access it.

The source code is your friend:

And yeah, you might be able to increase that frequency with a simple plugin, but be wary of the resource and performance impact you might have.

4 Likes

Fair enough, this is what we were thinking the issue was about, I forgot to check the source code as I did not expect it to be there, though it makes perfect sense!

Thanks for the quick answer!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.