dmbf29 / predictor-api

match prediction app / back-end API built on Rails
1 stars 4 forks source link

Add Global Top 10 Leaderboard #111

Closed trouni closed 1 year ago

trouni commented 1 year ago

Changes in this PR

Modifications to the Leaderboard model

Four attributes have been added to the Leaderboard model:

Refactoring of seeds

The seeds have been refactored in order to allow using multiple seeds files inside the db/seeds folder. rake db:seed will run all the files inside the db/seeds folder. Since the order of execution matters, I have moved the content of the previous seeds.rb file into a 0_default.rb file, but we could also split this into separate files in the future.

In order to seed the global leaderboard, we should run this rake task:

rake db:seed:1_leaderboards

Remaining tasks

Some changes still need to be made in the FE:

Related issues

Fixes #107, fixes trouni/predictor-vue#215

trouni commented 1 year ago

@dmbf29 Don't pay attention to the long commit history, I didn't branch out from the most recent main... Only the last 2 commits are relevant to this PR.

dmbf29 commented 1 year ago

Also noticed a review question doesn't get pinged in our Slack ☝️

dmbf29 commented 1 year ago

takes 3 minutes to create memberships for every competition 🤔 should take seconds...

trouni commented 1 year ago

takes 3 minutes to create memberships for every competition 🤔 should take seconds...

Yeah I know what's happening. I noticed as well that updating predictions is taking longer than usual, because the views are being refreshed after we create/update any of those records.

I will move the refreshing to an asynchronous job to speed things up, and will try to prevent the callback from triggering in the seeds.

trouni commented 1 year ago

Yeah that's an issue with the FE, it happens sometimes, I need to look into it. Unrelated to this BE feature though.

I've updated the PR. Can you try again? Maybe test the scraping/API jobs as well just in case?

trouni commented 1 year ago

Btw, the diff looks scary, but I just wrapped some of the actions in a block to prevent the callback from triggering...

DatabaseViews.run_without_callback(then_refresh: true) do
    # Do something
end