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

Changed database column for wrestlers seed to bracket_line

This commit is contained in:
2018-09-17 14:29:00 +00:00
parent 1cfe818d14
commit 436e716cd4
11 changed files with 149 additions and 144 deletions

View File

@@ -61,7 +61,7 @@ class Weight < ActiveRecord::Base
def poolSeedOrder(pool)
# wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
return wrestlersForPool(pool).sort_by{|w|w.seed}
return wrestlersForPool(pool).sort_by{|w|w.bracket_line}
end

View File

@@ -14,14 +14,14 @@ class TournamentSeeding
def randomSeeding(weight)
wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }.sort_by{|w| w.original_seed}
if wrestlerWithSeeds.size > 0
highestSeed = wrestlerWithSeeds.last.seed
highestSeed = wrestlerWithSeeds.last.bracket_line
seed = highestSeed + 1
else
seed = 1
end
wrestlersWithoutSeed = weight.wrestlers.select{|w| w.original_seed == nil }
wrestlersWithoutSeed.shuffle.each do |w|
w.seed = seed
w.bracket_line = seed
w.save
seed += 1
end
@@ -30,14 +30,14 @@ class TournamentSeeding
def setOriginalSeeds(weight)
wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }
wrestlerWithSeeds.each do |w|
w.seed = w.original_seed
w.bracket_line = w.original_seed
w.save
end
end
def resetAllSeeds(weight)
weight.wrestlers.each do |w|
w.seed = nil
w.bracket_line = nil
w.save
end
end

View File

@@ -1,77 +1,77 @@
class GeneratePoolNumbers
def initialize( weight )
@weight = weight
end
def savePoolNumbers
if @weight.pools == 4
saveFourPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 2
saveTwoPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 1
saveOnePoolNumbers(@weight.wrestlersWithoutPool)
end
end
def saveOnePoolNumbers(poolWrestlers)
poolWrestlers.sort_by{|x| x.seed }.each do |w|
w.pool = 1
w.save
end
end
def saveTwoPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.pool = 1
elsif w.seed == 2
w.pool = 2
elsif w.seed == 3
w.pool = 2
elsif w.seed == 4
w.pool = 1
else
w.pool = pool
end
if pool < 2
pool = pool + 1
else
pool = 1
end
w.save
end
end
def saveFourPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.pool = 1
elsif w.seed == 2
w.pool = 2
elsif w.seed == 3
w.pool = 3
elsif w.seed == 4
w.pool = 4
elsif w.seed == 8
w.pool = 1
elsif w.seed == 7
w.pool = 2
elsif w.seed == 6
w.pool = 3
elsif w.seed == 5
w.pool = 4
else
w.pool = pool
end
if pool < 4
pool = pool + 1
else
pool = 1
end
w.save
end
end
class GeneratePoolNumbers
def initialize( weight )
@weight = weight
end
def savePoolNumbers
if @weight.pools == 4
saveFourPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 2
saveTwoPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 1
saveOnePoolNumbers(@weight.wrestlersWithoutPool)
end
end
def saveOnePoolNumbers(poolWrestlers)
poolWrestlers.sort_by{|x| x.bracket_line }.each do |w|
w.pool = 1
w.save
end
end
def saveTwoPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.bracket_line }.reverse.each do |w|
if w.bracket_line == 1
w.pool = 1
elsif w.bracket_line == 2
w.pool = 2
elsif w.bracket_line == 3
w.pool = 2
elsif w.bracket_line == 4
w.pool = 1
else
w.pool = pool
end
if pool < 2
pool = pool + 1
else
pool = 1
end
w.save
end
end
def saveFourPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.bracket_line }.reverse.each do |w|
if w.bracket_line == 1
w.pool = 1
elsif w.bracket_line == 2
w.pool = 2
elsif w.bracket_line == 3
w.pool = 3
elsif w.bracket_line == 4
w.pool = 4
elsif w.bracket_line == 8
w.pool = 1
elsif w.bracket_line == 7
w.pool = 2
elsif w.bracket_line == 6
w.pool = 3
elsif w.bracket_line == 5
w.pool = 4
else
w.pool = pool
end
if pool < 4
pool = pool + 1
else
pool = 1
end
w.save
end
end
end

View File

@@ -10,18 +10,18 @@ class SwapWrestlers
w3 = Wrestler.new
w3.weight_id = w1.weight_id
w3.original_seed = w1.original_seed
w3.seed = w1.seed
w3.bracket_line = w1.bracket_line
w3.pool = w1.pool
swapWrestlerMatches(w1.allMatches,w1.id,w3.id)
#Swap wrestler 1 and wrestler 2
swapWrestlerMatches(w2.allMatches,w2.id,w1.id)
w1.seed = w2.seed
w1.bracket_line = w2.bracket_line
w1.pool = w2.pool
swapWrestlerMatches(w3.allMatches,w3.id,w2.id)
w2.seed = w3.seed
w2.bracket_line = w3.bracket_line
w2.pool = w3.pool

View File

@@ -15,7 +15,7 @@
</tr>
</thead>
<tbody>
<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.seed}.each do |w| %>
<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.bracket_line}.each do |w| %>
<tr>
<td><%= w.original_seed %> <%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %></td>
<% @round = 1 %>

View File

@@ -0,0 +1,5 @@
class ChangeSeedColumnToBracketLine < ActiveRecord::Migration[5.2]
def change
rename_column :wrestlers, :seed, :bracket_line
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170301174920) do
ActiveRecord::Schema.define(version: 2018_09_17_133030) do
create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
@@ -136,7 +136,7 @@ ActiveRecord::Schema.define(version: 20170301174920) do
t.string "name"
t.integer "school_id"
t.integer "weight_id"
t.integer "seed"
t.integer "bracket_line"
t.integer "original_seed"
t.datetime "created_at"
t.datetime "updated_at"

View File

@@ -6,7 +6,7 @@ tournament_1_wrestler_1:
school_id: 1
weight_id: 1
original_seed: 3
seed: 2
bracket_line: 2
season_loss: 8
season_win: 30
criteria: SQ
@@ -19,7 +19,7 @@ tournament_1_wrestler_2:
school_id: 1
weight_id: 1
original_seed: 5
seed: 5
bracket_line: 5
season_loss: 12
season_win: 30
criteria: DP 6th
@@ -32,7 +32,7 @@ tournament_1_wrestler_3:
school_id: 1
weight_id: 1
original_seed: 1
seed: 1
bracket_line: 1
season_loss: 3
season_win: 49
criteria: SP 2nd
@@ -45,7 +45,7 @@ tournament_1_wrestler_4:
school_id: 1
weight_id: 1
original_seed: 4
seed: 4
bracket_line: 4
season_loss: 8
season_win: 30
criteria: DP 5th
@@ -58,7 +58,7 @@ tournament_1_wrestler_5:
school_id: 1
weight_id: 1
original_seed: 2
seed: 3
bracket_line: 3
season_loss: 12
season_win: 49
criteria: SP 5th
@@ -71,7 +71,7 @@ tournament_1_wrestler_6:
school_id: 1
weight_id: 2
original_seed: 6
seed: 3
bracket_line: 3
season_loss: 15
season_win: 16
criteria:
@@ -84,7 +84,7 @@ tournament_1_wrestler_7:
school_id: 1
weight_id: 2
original_seed: 5
seed: 5
bracket_line: 5
season_loss: 15
season_win: 16
criteria: DQ
@@ -97,7 +97,7 @@ tournament_1_wrestler_8:
school_id: 1
weight_id: 2
original_seed: 2
seed: 2
bracket_line: 2
season_loss: 2
season_win: 50
criteria: SQ
@@ -110,7 +110,7 @@ tournament_1_wrestler_9:
school_id: 1
weight_id: 2
original_seed: 3
seed: 6
bracket_line: 6
season_loss: 5
season_win: 40
criteria: SQ
@@ -123,7 +123,7 @@ tournament_1_wrestler_10:
school_id: 1
weight_id: 2
original_seed: 7
seed: 4
bracket_line: 4
season_loss: 2
season_win: 50
criteria:
@@ -136,7 +136,7 @@ tournament_1_wrestler_11:
school_id: 1
weight_id: 2
original_seed: 4
seed: 7
bracket_line: 7
season_loss: 15
season_win: 20
criteria: DP 6th
@@ -149,7 +149,7 @@ tournament_1_wrestler_12:
school_id: 1
weight_id: 2
original_seed: 1
seed: 1
bracket_line: 1
season_loss: 4
season_win: 30
criteria: SP 7th
@@ -162,7 +162,7 @@ tournament_1_wrestler_13:
school_id: 1
weight_id: 3
original_seed: 1
seed: 1
bracket_line: 1
season_loss: 2
season_win: 50
criteria:
@@ -175,7 +175,7 @@ tournament_1_wrestler_14:
school_id: 1
weight_id: 3
original_seed: 8
seed: 3
bracket_line: 3
season_loss: 2
season_win: 50
criteria:
@@ -188,7 +188,7 @@ tournament_1_wrestler_15:
school_id: 1
weight_id: 3
original_seed: 6
seed: 6
bracket_line: 6
season_loss: 2
season_win: 50
criteria:
@@ -201,7 +201,7 @@ tournament_1_wrestler_16:
school_id: 1
weight_id: 3
original_seed: 2
seed: 2
bracket_line: 2
season_loss: 2
season_win: 50
criteria:
@@ -214,7 +214,7 @@ tournament_1_wrestler_17:
school_id: 1
weight_id: 3
original_seed: 3
seed: 8
bracket_line: 8
season_loss: 2
season_win: 50
criteria:
@@ -227,7 +227,7 @@ tournament_1_wrestler_18:
school_id: 1
weight_id: 3
original_seed: 7
seed: 7
bracket_line: 7
season_loss: 2
season_win: 50
criteria:
@@ -240,7 +240,7 @@ tournament_1_wrestler_19:
school_id: 1
weight_id: 3
original_seed: 9
seed: 4
bracket_line: 4
season_loss: 2
season_win: 50
criteria:
@@ -253,7 +253,7 @@ tournament_1_wrestler_20:
school_id: 1
weight_id: 3
original_seed: 5
seed: 5
bracket_line: 5
season_loss: 2
season_win: 50
criteria:
@@ -266,7 +266,7 @@ tournament_1_wrestler_21:
school_id: 1
weight_id: 3
original_seed: 4
seed: 9
bracket_line: 9
season_loss: 2
season_win: 50
criteria:
@@ -279,7 +279,7 @@ tournament_1_wrestler_22:
school_id: 1
weight_id: 4
original_seed: 10
seed: 7
bracket_line: 7
season_loss: 2
season_win: 50
criteria:
@@ -292,7 +292,7 @@ tournament_1_wrestler_23:
school_id: 1
weight_id: 4
original_seed: 2
seed: 2
bracket_line: 2
season_loss: 2
season_win: 50
criteria:
@@ -305,7 +305,7 @@ tournament_1_wrestler_24:
school_id: 1
weight_id: 4
original_seed: 6
seed: 6
bracket_line: 6
season_loss: 2
season_win: 50
criteria:
@@ -318,7 +318,7 @@ tournament_1_wrestler_25:
school_id: 1
weight_id: 4
original_seed: 3
seed: 3
bracket_line: 3
season_loss: 2
season_win: 50
criteria:
@@ -331,7 +331,7 @@ tournament_1_wrestler_26:
school_id: 1
weight_id: 4
original_seed: 5
seed: 5
bracket_line: 5
season_loss: 2
season_win: 50
criteria:
@@ -344,7 +344,7 @@ tournament_1_wrestler_27:
school_id: 1
weight_id: 4
original_seed: 11
seed: 8
bracket_line: 8
season_loss: 2
season_win: 50
criteria:
@@ -357,7 +357,7 @@ tournament_1_wrestler_28:
school_id: 1
weight_id: 4
original_seed: 1
seed: 1
bracket_line: 1
season_loss: 2
season_win: 50
criteria:
@@ -370,7 +370,7 @@ tournament_1_wrestler_29:
school_id: 1
weight_id: 4
original_seed: 4
seed: 4
bracket_line: 4
season_loss: 2
season_win: 50
criteria:
@@ -383,7 +383,7 @@ tournament_1_wrestler_30:
school_id: 1
weight_id: 4
original_seed: 8
seed: 11
bracket_line: 11
season_loss: 2
season_win: 50
criteria:
@@ -396,7 +396,7 @@ tournament_1_wrestler_31:
school_id: 1
weight_id: 4
original_seed: 7
seed: 10
bracket_line: 10
season_loss: 2
season_win: 50
criteria:
@@ -409,7 +409,7 @@ tournament_1_wrestler_32:
school_id: 1
weight_id: 4
original_seed: 9
seed: 9
bracket_line: 9
season_loss: 2
season_win: 50
criteria:
@@ -422,7 +422,7 @@ tournament_1_wrestler_33:
school_id: 1
weight_id: 5
original_seed: 15
seed: 7
bracket_line: 7
season_loss: 2
season_win: 50
criteria:
@@ -435,7 +435,7 @@ tournament_1_wrestler_34:
school_id: 1
weight_id: 5
original_seed: 10
seed: 10
bracket_line: 10
season_loss: 2
season_win: 50
criteria:
@@ -448,7 +448,7 @@ tournament_1_wrestler_35:
school_id: 1
weight_id: 5
original_seed: 1
seed: 1
bracket_line: 1
season_loss: 2
season_win: 50
criteria:
@@ -461,7 +461,7 @@ tournament_1_wrestler_36:
school_id: 1
weight_id: 5
original_seed: 11
seed: 11
bracket_line: 11
season_loss: 2
season_win: 50
criteria:
@@ -474,7 +474,7 @@ tournament_1_wrestler_37:
school_id: 1
weight_id: 5
original_seed: 2
seed: 2
bracket_line: 2
season_loss: 2
season_win: 50
criteria:
@@ -487,7 +487,7 @@ tournament_1_wrestler_38:
school_id: 1
weight_id: 5
original_seed: 13
seed: 13
bracket_line: 13
season_loss: 2
season_win: 50
criteria:
@@ -500,7 +500,7 @@ tournament_1_wrestler_39:
school_id: 1
weight_id: 5
original_seed: 8
seed: 16
bracket_line: 16
season_loss: 2
season_win: 50
criteria:
@@ -513,7 +513,7 @@ tournament_1_wrestler_40:
school_id: 1
weight_id: 5
original_seed: 5
seed: 5
bracket_line: 5
season_loss: 2
season_win: 50
criteria:
@@ -526,7 +526,7 @@ tournament_1_wrestler_41:
school_id: 1
weight_id: 5
original_seed: 14
seed: 6
bracket_line: 6
season_loss: 2
season_win: 50
criteria:
@@ -539,7 +539,7 @@ tournament_1_wrestler_42:
school_id: 1
weight_id: 5
original_seed: 9
seed: 9
bracket_line: 9
season_loss: 2
season_win: 50
criteria:
@@ -552,7 +552,7 @@ tournament_1_wrestler_43:
school_id: 1
weight_id: 5
original_seed: 6
seed: 14
bracket_line: 14
season_loss: 2
season_win: 50
criteria:
@@ -565,7 +565,7 @@ tournament_1_wrestler_44:
school_id: 1
weight_id: 5
original_seed: 7
seed: 15
bracket_line: 15
season_loss: 2
season_win: 50
criteria:
@@ -578,7 +578,7 @@ tournament_1_wrestler_45:
school_id: 1
weight_id: 5
original_seed: 16
seed: 8
bracket_line: 8
season_loss: 2
season_win: 50
criteria:
@@ -591,7 +591,7 @@ tournament_1_wrestler_46:
school_id: 1
weight_id: 5
original_seed: 12
seed: 12
bracket_line: 12
season_loss: 2
season_win: 50
criteria:
@@ -604,7 +604,7 @@ tournament_1_wrestler_47:
school_id: 1
weight_id: 5
original_seed: 3
seed: 3
bracket_line: 3
season_loss: 2
season_win: 50
criteria:
@@ -617,7 +617,7 @@ tournament_1_wrestler_48:
school_id: 1
weight_id: 5
original_seed: 4
seed: 4
bracket_line: 4
season_loss: 2
season_win: 50
criteria:
@@ -630,7 +630,7 @@ tournament_1_wrestler_49:
school_id: 1
weight_id: 6
original_seed:
seed: 6
bracket_line: 6
season_loss: 2
season_win: 50
criteria:
@@ -643,7 +643,7 @@ tournament_1_wrestler_50:
school_id: 1
weight_id: 6
original_seed: 2
seed: 2
bracket_line: 2
season_loss: 2
season_win: 50
criteria:
@@ -656,7 +656,7 @@ tournament_1_wrestler_51:
school_id: 1
weight_id: 6
original_seed:
seed: 5
bracket_line: 5
season_loss: 2
season_win: 50
criteria:
@@ -669,7 +669,7 @@ tournament_1_wrestler_52:
school_id: 1
weight_id: 6
original_seed:
seed: 3
bracket_line: 3
season_loss: 2
season_win: 50
criteria:
@@ -682,7 +682,7 @@ tournament_1_wrestler_53:
school_id: 1
weight_id: 6
original_seed:
seed: 4
bracket_line: 4
season_loss: 2
season_win: 50
criteria:

View File

@@ -260,7 +260,7 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
test "Random seeding works" do
weight = Weight.find(6)
wrestlersWithoutSeed = weight.wrestlers.select{|w| w.seed == nil }.size
wrestlersWithoutSeed = weight.wrestlers.select{|w| w.bracket_line == nil }.size
assert_equal 0, wrestlersWithoutSeed
end

View File

@@ -42,7 +42,7 @@ class SingleTestTest < ActionDispatch::IntegrationTest
# puts " school_id: #{w.school_id}"
# puts " weight_id: #{w.weight_id}"
# puts " original_seed: #{w.original_seed}"
# puts " seed: #{w.seed}"
# puts " bracket_line: #{w.bracket_line}"
# puts " season_loss: #{w.season_loss}"
# puts " season_win: #{w.season_win}"
# puts " criteria: #{w.criteria}"

View File

@@ -19,10 +19,10 @@ class SwapWrestlersTest < ActionDispatch::IntegrationTest
assert_not_empty wrestler1.matchAgainst(wrestler3)
assert_equal 2, wrestler1.pool
assert_equal 2, wrestler1.seed
assert_equal 2, wrestler1.bracket_line
assert_not_empty wrestler2.matchAgainst(wrestler4)
assert_equal 1, wrestler2.pool
assert_equal 1, wrestler2.seed
assert_equal 1, wrestler2.bracket_line
end
end