cancel
Showing results for 
Search instead for 
Did you mean: 

Number of forum members online is wrong !

Community Veteran
Posts: 5,472
Thanks: 292
Fixes: 4
Registered: ‎11-08-2007

Number of forum members online is wrong !

@jaread83

 

The number shown after "Who's Online" does not match the number of avatars displayed.

 

I did check whether this was a transient problem such as someone logging-in or leaving while the display was being created, but I left the page then came back twice, and the inconsistency was still there.

 

No matter why the number might be different, the figure shown should always match the number of avatars displayed.

 

WhosOnline24.jpg

WhosOnline30.jpg

11 REPLIES
jab1
Seasoned Champion
Posts: 2,278
Thanks: 619
Fixes: 9
Registered: ‎24-02-2012

Re: Number of forum members online is wrong !

@Nibiru That is something I haven't seen before, but I have noticed that I 'disappear' from the list occaisionally - Jack is aware of this and has a case open with Lithium.

John
Superuser
Superuser
Posts: 3,498
Thanks: 1,953
Fixes: 12
Registered: ‎10-04-2007

Re: Number of forum members online is wrong !

It is quite likely linked to this report https://community.plus.net/t5/Community-Site-Feedback/Not-showing-as-online/m-p/1482922#M13515 in some way.?

Both symptoms could be fixed in the same change?

jab1
Seasoned Champion
Posts: 2,278
Thanks: 619
Fixes: 9
Registered: ‎24-02-2012

Re: Number of forum members online is wrong !

Thamks @MauriceC - I was just looking for that post to link to!Smiley

John
Community Gaffer
Community Gaffer
Posts: 3,401
Thanks: 2,201
Fixes: 78
Registered: ‎22-02-2016

Re: Number of forum members online is wrong !

I am going to be looking at redeveloping the online user component as its quite a heavy load on the system. The user list (of avatars) comes from the 'V1' api whereas the rest of it (online user count, ranks, etc) all come from the 'V2' api which id done with a loop in the code to iterate over each user, building up the list with extras added. Both versions have its merits but sometimes I feel that both the APIs don't display the correct information in tandem with each other. So, for example, getting the list of user avatars from V1 will bring me back 30 users but the V2 may bring back a different number of online users. It may be counting 'invisible' users which I would need to test for.

Frontend Web Developer | www.plus.net

If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.

Community Veteran
Posts: 5,671
Thanks: 1,564
Fixes: 37
Registered: ‎16-10-2014

Re: Number of forum members online is wrong !

@jaread83 - Not to sure how you’re going to do this but I’m assuming JavaScript, if this is the case then can I suggest that you might want to build a union of the data from the two sources that exclude those not in the V2 range, a function with a custom or lambda comparator should do this for you if native support doesn’t exist.

Community Gaffer
Community Gaffer
Posts: 3,401
Thanks: 2,201
Fixes: 78
Registered: ‎22-02-2016

Re: Number of forum members online is wrong !

No javascript is used in the onlineusers component. Its Java based which adds a whole level of hurt to it.

Frontend Web Developer | www.plus.net

If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.

Community Gaffer
Community Gaffer
Posts: 3,401
Thanks: 2,201
Fixes: 78
Registered: ‎22-02-2016

Re: Number of forum members online is wrong !

To add to this, i am using the V1 api to get the list of online + registered users as its not available in the V2 api. The V1 api also has just the basics (no rank is shown for example) so this is all looked up within the loop for each entry shown for the V1 call.

Frontend Web Developer | www.plus.net

If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.

Community Veteran
Posts: 5,671
Thanks: 1,564
Fixes: 37
Registered: ‎16-10-2014

Re: Number of forum members online is wrong !

I’m confused? These APIs are they both Java for the V1 and V2 data sources? And are the objects returned by these POJOs? If that’s the case then even better from a programming point of view as you’ll be able to unionise these in code using the approach I mentioned above.

Community Gaffer
Community Gaffer
Posts: 3,401
Thanks: 2,201
Fixes: 78
Registered: ‎22-02-2016

Re: Number of forum members online is wrong !

The online user component will be redeveloped at some point soon and I will take that into consideration @Mook Smiley

My main aim for redeveloping it is to make it a lot faster as its the one component on this site that takes up the most resource. What I will likely do is what you suggest and build a new json string from the two APIs or I could simplify it a little bit.

As well as that I will need to see why the number of online users differs between the two and try and narrow down what makes it think that there is 1 more in the counter than there is in the avatar listing.

Frontend Web Developer | www.plus.net

If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.

Highlighted
Community Veteran
Posts: 5,671
Thanks: 1,564
Fixes: 37
Registered: ‎16-10-2014

Re: Number of forum members online is wrong !

As you know a lot of clock cycles are consumed when you’re doing multiple loops i.e. a loop within a loop. Please don’t think I’m teaching you to suck eggs but may I suggest further that when you find an item within your inner loop based on the search conditions of the outer, you remove it from the inner loop’s collection as looking at it again on a subsequent loops it redundant and a waste of time. Also exiting the inner loop at this point can also save time.

As you’re in Java land you could create a custom container class that stores the objects of the user’s you want to display. So again when you find a match within your inner loop you then add the new distinct user to the custom collection class. To take this further you could even create a new (Java) User class, that has sensible defaults in it, and supports multiple constructors. For example default User object instance would have a default outline avatar and any custom avatar could be set using an overloaded constructor.

When you want to use the data in the component you can have it automatically create the required JSON string, and with custom comparators the output can be sorted in any order you need prior to output. OK, I'll stop now.

As for the additional item, could this be related to user’s who hide their online status (like me)?

Community Gaffer
Community Gaffer
Posts: 3,401
Thanks: 2,201
Fixes: 78
Registered: ‎22-02-2016

Re: Number of forum members online is wrong !

As far as I know, invisible users do not get listed in the V1 api call to get the list of users (unless you are admin... I SEE ALL!). There might be a discrepency on the V2 counter when viewed by a user who is not an admin and is invisible themselves (as evidenced in the OP screenshots having the counter be 1 more than the avatar numbers.

The component code itself cannot be overly complicated with OOP as that just isn't possible. I am basically using freemarker and building the component in a single block so not sure how extensive I can be with creating objects and classes within it.

Frontend Web Developer | www.plus.net

If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.