From 523e124c47b640ced69b0789d7ab527d90537af6 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 30 Jan 2019 13:34:58 +0000 Subject: [PATCH] Added a rake task for finishing all matches and updated the readme --- README.rdoc | 19 +++++-------------- lib/tasks/finish_seed_tournament.rake | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 lib/tasks/finish_seed_tournament.rake diff --git a/README.rdoc b/README.rdoc index f4e5f72..19feca4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -16,22 +16,18 @@ MIT License Development details: -* Ruby 2.4.0 +* Ruby 2.5.1 -* Rails 5.1.1 +* Rails 5.2.2 * Install gems without production bundle install --without production -* Set local development variables for the applicaiton to work - -export WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 - -export WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa - * Test with minitest rake test * Seeds created for development rake db:seed +* Finish all matches from seed data (this take ~ 5 minutes) rake finish_seed_tournament + * Development login email: test@test.com password: password Docker instructions: @@ -72,9 +68,4 @@ MIT License MEMCACHIER_USERNAME=memcachier_username this is only needed for caching -* Production docker image: Run bash rails-prod.sh wrestlingapp. This will create a self-signed ssl certificate and set up wrestlingapp on passenger/apache. The container will run with port 80 and port 443 open and will have a restart policy of always. - - -Public Trello page: - -https://trello.com/b/OIF9s2Gw +* Production docker image: Run bash rails-prod.sh wrestlingapp. This will create a self-signed ssl certificate and set up wrestlingapp on passenger/apache. The container will run with port 80 and port 443 open and will have a restart policy of always. \ No newline at end of file diff --git a/lib/tasks/finish_seed_tournament.rake b/lib/tasks/finish_seed_tournament.rake new file mode 100644 index 0000000..1a6da13 --- /dev/null +++ b/lib/tasks/finish_seed_tournament.rake @@ -0,0 +1,17 @@ +task :finish_seed_tournament => :environment do + @tournament = Tournament.where(:id => 200).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first + GenerateTournamentMatches.new(@tournament).generate + (1..@tournament.reload.total_rounds).each do |round| + @tournament.reload.matches_by_round(round).each do |match| + match.reload + if match.wrestler1.bracket_line < match.wrestler2.bracket_line + match.winner_id = match.w1 + else + match.winner_id = match.w2 + end + match.finished = 1 + match.score = "2-1" + match.save + end + end +end \ No newline at end of file