1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

I think I got delayed jobs working

This commit is contained in:
2015-12-29 18:50:18 +00:00
parent 106291fbaf
commit 0d310c587b
6 changed files with 18 additions and 1 deletions

View File

@@ -52,6 +52,7 @@ gem 'spring', :group => :development
gem 'cancancan' gem 'cancancan'
gem 'round_robin_tournament' gem 'round_robin_tournament'
gem 'rb-readline' gem 'rb-readline'
gem 'delayed_job_active_record'
group :development do group :development do
gem 'puma' gem 'puma'
#gem 'bullet' #gem 'bullet'

View File

@@ -49,6 +49,11 @@ GEM
coffee-script-source (1.9.1.1) coffee-script-source (1.9.1.1)
concurrent-ruby (1.0.0) concurrent-ruby (1.0.0)
dalli (2.7.5) dalli (2.7.5)
delayed_job (4.1.1)
activesupport (>= 3.0, < 5.0)
delayed_job_active_record (4.1.0)
activerecord (>= 3.0, < 5)
delayed_job (>= 3.0, < 5)
devise (3.4.1) devise (3.4.1)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
@@ -162,6 +167,7 @@ DEPENDENCIES
cancancan cancancan
coffee-rails (~> 4.0.0) coffee-rails (~> 4.0.0)
dalli dalli
delayed_job_active_record
devise devise
jbuilder (~> 2.0) jbuilder (~> 2.0)
jquery-rails jquery-rails

View File

@@ -4,6 +4,11 @@ class Match < ActiveRecord::Base
belongs_to :mat, touch: true belongs_to :mat, touch: true
has_many :wrestlers, :through => :weight has_many :wrestlers, :through => :weight
if Rails.env.production?
handle_asynchronously :advance_wrestlers
handle_asynchronously :calcSchoolPoints
end
after_update do after_update do
if self.finished == 1 && self.winner_id != nil if self.finished == 1 && self.winner_id != nil
if self.w1 && self.w2 if self.w1 && self.w2

View File

@@ -9,6 +9,10 @@ class Tournament < ActiveRecord::Base
has_many :wrestlers, through: :weights has_many :wrestlers, through: :weights
has_many :matches, dependent: :destroy has_many :matches, dependent: :destroy
if Rails.env.production?
handle_asynchronously :generateMatchups
end
def resetSchoolScores def resetSchoolScores
schools.update_all("score = 0.0") schools.update_all("score = 0.0")
end end

View File

@@ -1,3 +1,3 @@
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %> <%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<br><br> <br><br>
Matches successfully generated. Matches are being generated. This can take anywhere from 1-5 minutes to finish.

View File

@@ -26,6 +26,7 @@ module Wrestling
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
#gzip assets #gzip assets
config.middleware.use Rack::Deflater config.middleware.use Rack::Deflater
config.active_job.queue_adapter = :delayed_job
end end