[nodebb-widget-board-stats] discrepancy to dashboard count

NodeBB Plugins
  • hi.

    i'm still pretty new to nodeBB - it's my second thread.  we are a group of seven enthusiasts who moved a nearly 20 year old voluntary sports-forum in germany from a proprietary internet forum software to nodeBB.  ... and we are still happy with our choice =;^)  it's a great piece of software!

    we are using the nodebb-widget-board-stats widget in a self-localized and customized version.  we found a distinct discrepancy of the active users count shown by the widget compared to the dashboard.  as far as i understand the active users count is calculated by

    105        db.sortedSetCount('users:online', now - 300000, '+inf', next);
    

    of library.js while the guest count is required by

    108        require.main.require('./src/socket.io/admin/rooms').getTotalGuestCount(function (err, guestCount) { ...
    

    as a live-value from nodeBB.  unfortunately i have no idea where the active users count shown in the dashboard comes from.  it's definitely not calculated the same way!

    we had to treble the span of time from 300000 to 900000 like in

    105        db.sortedSetCount('users:online', now - 900000, '+inf', next);
    

    to come closer to the active users count shown in the dashboard but it depends on some undisclosed criteria - user activities or devices or whatever - that both values still differ significantly in both directions.  my questions are:

    1. how is the active users count shown in the dashboard required?
    2. how to get the same value for the nodebb-widget-board-stats plugin?

    some other thoughts: i'm wondering why the span of time is hard coded in the widget.  from a more user perspective i would expect the "onlineCutoff" found in the "config" key is taken into account.  in both places!

    ... and i have an additional "{count24h} users were active for the last 24 hours." on my personal wishlist, based on something like

    ...        db.sortedSetCount('users:online', now - 8640000, '+inf', next);
    

    i will try to achieve this by myself.

    ober!schöne grüße,
    mrx.

  • Core uses the following to get the number of active users.

    db.getSortedSetCount('users:online', now - (meta.config.onlineCutoff * 60000), '+inf');

    This gives you the user count that is considered active, ie navigated or made a post in the past x minutes.

    The dashboard is more real time, the values shown there are calculate here

    If you want the same values as ACP you need to use SocketRooms.getOnlineUserCount(io);

  • @baris thank you for all the details.  i'll try to "fix" it by myself.


Suggested Topics