Dantevg/WebStats

Top Player

coco0325 opened this issue ยท 5 comments

It would be nice if it's able to show top players (for example, top 100) in a selected stat.
Perhaps they can be placed in multiple sheets.

Btw, https can be achieved by reverse proxy.

Heyo!

Thanks for the suggestion. I'm not quite sure what you mean though. Currently you can sort by clicking on any stat's header, that way you can see who are the top players for a given stat.
Do you mean that it would indicate where the top-100 ends, and give every player an index (1 to 100)?

And with sheets, do you mean dividing them up in pages, like with < prev and next > controls?

Thank you for the tip on https! If I read things correctly, doing reverse proxy is something that needs to be set up manually in the web server configuration right? I would want to support https automatically in-plugin, but adding a note about reverse proxy to the readme can be a nice first step! (once I read into it a bit more)

The main issue I encountered is on the MySQL function. For example, I want to display the players' stats in a relatively large table (more than 10k rows). The page will contain too much data and cause the browser to lag. If the plugin can pre-sort the stats and only send the top players' data, then the issue can be solved. However, this solution might force the site to display different stats in different sheets.

And yes, the following code is an example.

location /stats.json {
          proxy_pass http://ip:port/stats.json;
}

location /online.json {
          proxy_pass http://ip:port/online.json;
}

Well it has been a while. This is a feature that requires a lot of time so I thought I'd give a kind of status update.

I want to avoid changing the communication protocol because of backwards compatibility (I think that atm, you can use any version of the web files with any plugin version). Testing will reveal whether that is actually necessary.

The idea of showing only the top-100 is already implemented locally (haven't committed yet), and that already fixes the general browser lag. For the lag when sorting, I have two options I will be trying, in order:

  1. Optimise sorting in js. Change in communication is not necessary but may improve performance further
  2. Pre-sort all stats/columns on server. Requires a non-backwards-compatible change in the communication protocol. Since this just moves the performance hit to the server, some extra things are needed to prevent causing server lag:
    • Cache stats and sorting server-side: don't re-sort data for 30 seconds or so
    • Custom sorting algorithm that takes advantage of the fact that only stats for online players need to be re-sorted

So things are coming, but they will take some time ๐Ÿ˜Š

It turns out that the first option was already enough and it was not necessary to change the communication protocol ๐ŸŽ‰!
Here are the things that changed to improve performance (roughly ordered from most to least performance impact):

  • Add pagination, by default only show 100 players at a time
  • Optimise sorting method
  • Add option to hide player heads
  • When showing player heads, do not load images on hidden pages

You can use the latest js and html files which work just fine with the current jar and performance should be good now! I tested with 10k randomly generated entries on my laptop and the page was pretty responsive, let me know if it works for you as well!

It works very well. Thank you!