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.
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 thescore
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.