diff --git a/.circleci/config.yml b/.circleci/config.yml index 0edcd92..e821b27 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,8 @@ jobs: steps: - checkout - run: | + echo Deploys are happening on my home Jenkins server + echo this is a placeholder in case I want to move that cat >~/.netrc < :weight has_many :schools, :through => :wrestlers - validate :score_validation, :win_type_validation, :bracket_position_validation + validate :score_validation, :win_type_validation, :bracket_position_validation, :overtime_type_validation after_update :after_finished_actions, :if => :saved_change_to_finished? or :saved_change_to_winner_id? or :saved_change_to_win_type? or :saved_change_to_score? def after_finished_actions @@ -25,6 +25,7 @@ class Match < ActiveRecord::Base BRACKET_POSITIONS = ["Pool","1/2","3/4","5/6","7/8","Quarter","Semis","Conso Semis","Bracket","Conso", "Conso Quarter"] WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ", "BYE"] + OVERTIME_TYPES = ["", "SV-1", "TB-1", "UTB", "SV-2", "TB-2", "OT"] # had to keep the blank here for validations def score_validation if finished == 1 @@ -51,6 +52,13 @@ class Match < ActiveRecord::Base end end + def overtime_type_validation + # overtime_type can be nil or of type OVERTIME_TYPES + if overtime_type != nil and ! OVERTIME_TYPES.include? overtime_type + errors.add(:overtime_type, "can only be one of the following #{OVERTIME_TYPES.to_s}") + end + end + def bracket_position_validation if ! BRACKET_POSITIONS.include? bracket_position errors.add(:bracket_position, "can only be one of the following #{BRACKET_POSITIONS.to_s}") @@ -122,9 +130,11 @@ class Match < ActiveRecord::Base return "" end if self.finished == 1 - if self.win_type == "Default" - return "(Def)" - elsif self.win_type == "Injury Default" + overtime_type_abbreviation = "" + if self.overtime_type != "" and self.overtime_type + overtime_type_abbreviation = " #{self.overtime_type}" + end + if self.win_type == "Injury Default" return "(Inj)" elsif self.win_type == "DQ" return "(DQ)" @@ -132,7 +142,7 @@ class Match < ActiveRecord::Base return "(FF)" else win_type_abbreviation = "#{self.win_type.chars.to_a[0..2].join('')}" - return "(#{win_type_abbreviation} #{self.score})" + return "(#{win_type_abbreviation} #{self.score}#{overtime_type_abbreviation})" end end end diff --git a/app/services/tournament_services/wrestlingdev_importer.rb b/app/services/tournament_services/wrestlingdev_importer.rb index 45482c6..5354836 100644 --- a/app/services/tournament_services/wrestlingdev_importer.rb +++ b/app/services/tournament_services/wrestlingdev_importer.rb @@ -143,6 +143,7 @@ class WrestlingdevImporter new_match.loser1_name = match_array[13] new_match.loser2_name = match_array[14] # new_match.mat_id = mat_id if match_array[15].size > 0 + new_match.overtime_type = match_array[16] new_match.save end end diff --git a/app/views/matches/_matchstats.html.erb b/app/views/matches/_matchstats.html.erb index 0c7bd1a..f74c61f 100644 --- a/app/views/matches/_matchstats.html.erb +++ b/app/views/matches/_matchstats.html.erb @@ -83,13 +83,18 @@ <%= f.select(:win_type, Match::WIN_TYPES) %>
+
+ <%= f.label "Overtime Type" %> Leave blank if not overtime. For High School the 1st overtime is SV-1, second overtime is TB-1, third overtime is UTB.
+ <%= f.select(:overtime_type, Match::OVERTIME_TYPES) %> +
+
<%= f.label "Winner" %> Please choose the winner
<%= f.collection_select :winner_id, @wrestlers, :id, :name, include_blank: true %>

- <%= f.label "Final Score" %> For decision, major, or tech fall put the score here in Number-Number format. If pin, put the accumulated pin time in the format MM:SS. If default, injury default, dq, bye, or forfeit, leave blank. Examples: 7-2, 17-2, 0:30, or 2:34
+ <%= f.label "Final Score" %> For decision, major, or tech fall put the score here in Number-Number format. If pin, put the accumulated pin time in the format MM:SS. If default, injury default, dq, bye, or forfeit, leave blank. Examples: 7-2, 17-2, 0:30, or 2:34.
<%= f.text_field :score %>

diff --git a/app/views/tournaments/export.html.erb b/app/views/tournaments/export.html.erb index f07c617..4340799 100644 --- a/app/views/tournaments/export.html.erb +++ b/app/views/tournaments/export.html.erb @@ -19,4 +19,4 @@
--Wrestlers--<% @tournament.wrestlers.each do |wrestler| %><%= model_separator %><%= wrestler.name %><%= attribute_separator %><%= wrestler.school.name %><%= attribute_separator %><%= wrestler.weight.max %><%= attribute_separator %><%= wrestler.bracket_line %><%= attribute_separator %><%= wrestler.original_seed %><%= attribute_separator %><%= wrestler.season_win %><%= attribute_separator %><%= wrestler.season_loss %><%= attribute_separator %><%= wrestler.criteria %><%= attribute_separator %><%= wrestler.extra %><%= attribute_separator %><%= wrestler.offical_weight %><%= attribute_separator %><%= wrestler.pool %><%= attribute_separator %><%= wrestler.pool_placement %><%= attribute_separator %><%= wrestler.pool_placement_tiebreaker %><% end %>
---Matches--<% @tournament.matches.sort_by{|match| match.bout_number}.each do |match| %><%= model_separator %><%= Wrestler.where("id = ?",match.w1).first.name if match.w1 %><%= attribute_separator %><%= Wrestler.where("id = ?",match.w2).first.name if match.w2 %><%= attribute_separator %><%= match.w1_stat %><%= attribute_separator %><%= match.w2_stat %><%= attribute_separator %><%= Wrestler.where("id = ?",match.winner_id).first.name if match.winner_id %><%= attribute_separator %><%= match.win_type %><%= attribute_separator %><%= match.score %><%= attribute_separator %><%= match.round %><%= attribute_separator %><%= match.finished %><%= attribute_separator %><%= match.bout_number %><%= attribute_separator %><%= Weight.where("id = ?",match.weight_id).first.max if match.weight_id %><%= attribute_separator %><%= match.bracket_position %><%= attribute_separator %><%= match.bracket_position_number %><%= attribute_separator %><%= match.loser1_name %><%= attribute_separator %><%= match.loser2_name %><%= attribute_separator %><%= Mat.where("id = ?",match.mat_id).first.name if match.mat_id %><% end %> \ No newline at end of file +--Matches--<% @tournament.matches.sort_by{|match| match.bout_number}.each do |match| %><%= model_separator %><%= Wrestler.where("id = ?",match.w1).first.name if match.w1 %><%= attribute_separator %><%= Wrestler.where("id = ?",match.w2).first.name if match.w2 %><%= attribute_separator %><%= match.w1_stat %><%= attribute_separator %><%= match.w2_stat %><%= attribute_separator %><%= Wrestler.where("id = ?",match.winner_id).first.name if match.winner_id %><%= attribute_separator %><%= match.win_type %><%= attribute_separator %><%= match.score %><%= attribute_separator %><%= match.round %><%= attribute_separator %><%= match.finished %><%= attribute_separator %><%= match.bout_number %><%= attribute_separator %><%= Weight.where("id = ?",match.weight_id).first.max if match.weight_id %><%= attribute_separator %><%= match.bracket_position %><%= attribute_separator %><%= match.bracket_position_number %><%= attribute_separator %><%= match.loser1_name %><%= attribute_separator %><%= match.loser2_name %><%= attribute_separator %><%= Mat.where("id = ?",match.mat_id).first.name if match.mat_id %><% end %><%= attribute_separator %><%= match.overtime_type %> \ No newline at end of file diff --git a/db/migrate/20220912171922_add_overtime_to_match.rb b/db/migrate/20220912171922_add_overtime_to_match.rb new file mode 100644 index 0000000..804929f --- /dev/null +++ b/db/migrate/20220912171922_add_overtime_to_match.rb @@ -0,0 +1,5 @@ +class AddOvertimeToMatch < ActiveRecord::Migration[6.1] + def change + add_column :matches, :overtime_type, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 2693c4d..c7fa72b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_02_23_185853) do +ActiveRecord::Schema.define(version: 2022_09_12_171922) do create_table "delayed_jobs", force: :cascade do |t| t.integer "priority", default: 0, null: false @@ -49,6 +49,7 @@ ActiveRecord::Schema.define(version: 2022_02_23_185853) do t.string "loser1_name" t.string "loser2_name" t.integer "mat_id" + t.string "overtime_type" t.index ["mat_id"], name: "index_matches_on_mat_id" t.index ["tournament_id"], name: "index_matches_on_tournament_id" t.index ["w1", "w2"], name: "index_matches_on_w1_and_w2" diff --git a/test/models/match_test.rb b/test/models/match_test.rb index d5774fe..edda2e2 100644 --- a/test/models/match_test.rb +++ b/test/models/match_test.rb @@ -117,4 +117,13 @@ class MatchTest < ActiveSupport::TestCase match.save assert !match.valid? end + test "Match should not be valid if an incorrect overtime_type is given" do + create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8") + matches = @tournament.matches.reload + round1 = matches.select{|m| m.round == 1} + match = matches.first + match.overtime_type = "TEST" + match.save + assert !match.valid? + end end