mitre-cyber-academy / ctf-scoreboard-archive

Repository for the Deprecated MITRE Capture the Flag scoreboard.
Apache License 2.0
11 stars 10 forks source link

Optimize score calculation methods #28

Closed rbclark closed 8 years ago

rbclark commented 8 years ago

There is currently a ridiculous amount of time wasted in calculating the user ordering in filter_and_sort_players in the division model and most likely the score function in the player model (it takes nearly a second for these to process on every request and it is called on nearly every page which is slowing down the whole application). These should be rewritten to use SQL queries directly by doing a left join on the data and summing all directly in SQL. It is not very rails like but it will save a huge amount of time.

Will probably need to use rails .joins method with a left join for this, and then use the order method somehow.

rbclark commented 8 years ago

Fixed in https://github.com/mitre-cyber-academy/ctf-scoreboard/pull/29