mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-09 15:42:09 +00:00
Cut the runtime by queueing the changes in memory and deferring database writes
Made some unspecified behavior explicit
This commit is contained in:
@@ -16,13 +16,11 @@ class Tournament < ActiveRecord::Base
|
||||
def createCustomWeights(value)
|
||||
self.weights.destroy_all
|
||||
if value == 'hs'
|
||||
@weights = [106,113,120,132,138,145,152,160,170,182,195,220,285]
|
||||
end
|
||||
@weights.each do |w|
|
||||
newWeight = Weight.new
|
||||
newWeight.max = w
|
||||
newWeight.tournament_id = self.id
|
||||
newWeight.save
|
||||
Weight::HS_WEIGHT_CLASSES.each do |w|
|
||||
self.weights.create(max: w)
|
||||
end
|
||||
else
|
||||
raise "Unspecified behavior"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user