1
0
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:
RJ Osborne
2015-05-24 23:04:22 -04:00
parent 98879c16b9
commit 091b7c4181
5 changed files with 24 additions and 16 deletions

View File

@@ -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