From a9111836372da1c9e8e2f4e20ee62968354fbd52 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 29 Dec 2015 22:53:53 +0000 Subject: [PATCH] Trying to fix async jobs --- app/models/generates_tournament_matches.rb | 3 +++ app/models/match.rb | 11 +++++++---- app/models/tournament.rb | 4 +--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/models/generates_tournament_matches.rb b/app/models/generates_tournament_matches.rb index 4bc5917..e2dc649 100644 --- a/app/models/generates_tournament_matches.rb +++ b/app/models/generates_tournament_matches.rb @@ -4,6 +4,9 @@ module GeneratesTournamentMatches poolToBracket() if tournament_type == "Pool to bracket" matches end + if Rails.env.production? + handle_asynchronously :generateMatchups + end def poolToBracket resetSchoolScores diff --git a/app/models/match.rb b/app/models/match.rb index b83b362..95a37c4 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -4,10 +4,7 @@ class Match < ActiveRecord::Base belongs_to :mat, touch: true has_many :wrestlers, :through => :weight - if Rails.env.production? - handle_asynchronously :advance_wrestlers - handle_asynchronously :calcSchoolPoints - end + after_update do if self.finished == 1 && self.winner_id != nil @@ -28,6 +25,9 @@ class Match < ActiveRecord::Base wrestler2.school.calcScore end end + if Rails.env.production? + handle_asynchronously :calcSchoolPoints + end def mat_assigned if self.mat @@ -57,6 +57,9 @@ class Match < ActiveRecord::Base self.mat.assignNextMatch end end + if Rails.env.production? + handle_asynchronously :advance_wrestlers + end def bracketScore if self.finished != 1 diff --git a/app/models/tournament.rb b/app/models/tournament.rb index d4697fe..dd741f2 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -9,9 +9,7 @@ class Tournament < ActiveRecord::Base has_many :wrestlers, through: :weights has_many :matches, dependent: :destroy - if Rails.env.production? - handle_asynchronously :generateMatchups - end + def resetSchoolScores schools.update_all("score = 0.0")