Skip to content

chgk-gg/rating-importer

Repository files navigation

rating-importer

Imports data from rating.chgk.info for rating.maii.li calculations.

Rake tasks

All imports are rake tasks (defined in Rakefile). Each task is responsible for one resource (tournament details, tournament roster, team, town, etc.).

Import strategy

For each import, we:

  • create a temporary table (e.g., teams_temp);
  • import data into this temporary table;
  • record IDs of imported records into @ids (not autogenerated IDs from Postgres, but those provided by rating.chgk.info);
  • set updated_at for each imported row to DateTime.now;
  • in one transaction, delete from the main table all rows with IDs from @ids and insert everything from the temp table.

This is defined in strategies/temp_table.rb

Refresh data for one tournament

fly ssh console
cd app
bundle exec rake tournaments:results_for_single_tournament[6341]

Replace 6341 with the ID of the tournament you want to update.

Deployment

rating-b runs on Fly. Deployment is defined in fly.toml and has one process: supercronic /app/crontab.

Supercronic is recommended by Fly for cron jobs: it loads environment variables, forwards job logs to stdout and stderr, and handles sigterm signals. We install it in the final section of Dockerfile.

Cron jobs are set up in crontab.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published