From 6d21e8ebdf759f28b46e613766f7915148695287 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 30 Dec 2015 16:36:53 +0000 Subject: [PATCH] Show no matches while matches are being generated --- app/controllers/tournaments_controller.rb | 2 +- app/models/generates_tournament_matches.rb | 4 ++++ db/migrate/20151230163202_generating_matches.rb | 5 +++++ db/schema.rb | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20151230163202_generating_matches.rb diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 035e5a6..8694cad 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -144,7 +144,7 @@ class TournamentsController < ApplicationController def check_for_matches if @tournament - if @tournament.matches.empty? + if @tournament.matches.empty? or @tournament.curently_generating_matches == 1 redirect_to "/tournaments/#{@tournament.id}/no_matches" end end diff --git a/app/models/generates_tournament_matches.rb b/app/models/generates_tournament_matches.rb index 11fc2af..873bc27 100644 --- a/app/models/generates_tournament_matches.rb +++ b/app/models/generates_tournament_matches.rb @@ -1,9 +1,13 @@ module GeneratesTournamentMatches def generateMatchups + self.curently_generating_matches = 1 + self.save resetSchoolScores setSeedsAndRandomSeedingWrestlersWithoutSeeds poolToBracket() if tournament_type == "Pool to bracket" + self.curently_generating_matches = nil + self.save matches end if Rails.env.production? diff --git a/db/migrate/20151230163202_generating_matches.rb b/db/migrate/20151230163202_generating_matches.rb new file mode 100644 index 0000000..c27f573 --- /dev/null +++ b/db/migrate/20151230163202_generating_matches.rb @@ -0,0 +1,5 @@ +class GeneratingMatches < ActiveRecord::Migration + def change + add_column :tournaments, :curently_generating_matches, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index fd6390e..3d0b074 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151229220036) do +ActiveRecord::Schema.define(version: 20151230163202) do create_table "delayed_jobs", force: :cascade do |t| t.integer "priority", default: 0, null: false @@ -93,6 +93,7 @@ ActiveRecord::Schema.define(version: 20151229220036) do t.text "tournament_type" t.text "weigh_in_ref" t.integer "user_id" + t.integer "curently_generating_matches" end add_index "tournaments", ["user_id"], name: "index_tournaments_on_user_id"