Worldcubeassociation.org: Technical improvements of the rankings

Created on 11 Aug 2019  路  4Comments  路  Source: thewca/worldcubeassociation.org

After #4394 is merged, some of the code there should be improved. In particular, instead of using raw SQL for the queries, we should try to use ActiveRecord. At the moment, there are 4 different queries:

  1. "N persons": I believe using the RanksSingle/Average tables would be easier for this option. The problem I encountered is that those tables don't include the competitionId. Maybe this could be resolved by adding the competitionId to the tables? Or maybe we should just get the result.
  2. "N results": there are actually two different queries for this option, depending on if we want to show N single or average results. For the average option, simply getting the result should be enough. I'm not sure about the single one, but probably that would be more than enough too!
  3. "By region": I think in this case we could as well just get the result.
post-rails

All 4 comments

I don't think we can use RanksSingle for "N persons of some country/continent" because some competitors have changed their countries. They should show on "N persons" for their previous countries but their rankings are based on the current countries.

Another point: we could set up caching for rankings. The PHP cache is cleared as a part of CAD, so in Rails we could use CAD timestamp in cache key.

Maybe I didn't catch this somewhere, but it seems the "All" option is gone for rankings and you can only get 100/1000. This was intentional? (For both Person and Result.)

Screenshot_20190815-084621~2

The "All persons" option was not working anymore with the old PHP code, so I just got rid of it. Adding pagination as @jonatanklosko suggested here is an option to have it back! (And there wasn't an "All results" option.)

As a quick workaround: the number on the URL can be modified to show any arbitrary number of persons/results.

Was this page helpful?
0 / 5 - 0 ratings