mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-09 07:39:06 +00:00
Revert "Revert "Moving away from matchups_array and saving matches individually""
This reverts commit 7b3fe2aaad.
This commit is contained in:
@@ -2,4 +2,13 @@ class Match < ActiveRecord::Base
|
|||||||
belongs_to :tournament
|
belongs_to :tournament
|
||||||
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"]
|
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"]
|
||||||
|
|
||||||
|
|
||||||
|
def w1_name
|
||||||
|
Wrestler.find(self.w1).name
|
||||||
|
end
|
||||||
|
|
||||||
|
def w2_name
|
||||||
|
Wrestler.find(self.w2).name
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ class Tournament < ActiveRecord::Base
|
|||||||
|
|
||||||
def upcomingMatches
|
def upcomingMatches
|
||||||
# @matches = generateMatchups
|
# @matches = generateMatchups
|
||||||
if self.matchups_array
|
if self.matches.nil?
|
||||||
return matchupHashesToObjects(self.matchups_array)
|
return self.matches
|
||||||
else
|
else
|
||||||
@matches = generateMatchups
|
@matches = generateMatchups
|
||||||
saveMatchups(@matches)
|
puts @matches.inspect
|
||||||
return @matches
|
saveMatchups(@matches)
|
||||||
|
return @matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -34,8 +35,18 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def saveMatchups(matches)
|
def saveMatchups(matches)
|
||||||
self.matchups_array = matchupObjectsToHash(matches)
|
matches.each do |m|
|
||||||
self.save
|
@match = Match.new
|
||||||
|
@match.w1 = m.w1
|
||||||
|
@match.w2 = m.w2
|
||||||
|
@match.round = m.round
|
||||||
|
@match.boutNumber = m.boutNumber
|
||||||
|
@match.bracket_position = m.bracket_position
|
||||||
|
@match.bracket_position_number = m.bracket_position_number
|
||||||
|
@match.tournament_id = self.id
|
||||||
|
puts @match.inspect
|
||||||
|
@match.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,11 @@
|
|||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
<script src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
|
<script src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.map"></script>
|
||||||
|
|
||||||
|
<!-- File saver does more than excel exports but that is currently what we are using it for -->
|
||||||
|
<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script>
|
||||||
<style>
|
<style>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -3,11 +3,26 @@
|
|||||||
#html, #body, #wrapper { width:100%; }
|
#html, #body, #wrapper { width:100%; }
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script>
|
||||||
|
<script>
|
||||||
|
function exportDataToRtf() {
|
||||||
|
var blob = new Blob([document.getElementById("exportable").innerHTML], {
|
||||||
|
type: "application/octet-stream"
|
||||||
|
});
|
||||||
|
saveAs(blob, "brackets.rtf");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<%= link_to "Back to #{@tournament.name} weights", "/static_pages/weights?tournament=#{@tournament.id}" %>
|
<%= link_to "Back to #{@tournament.name} weights", "/static_pages/weights?tournament=#{@tournament.id}" %>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
<button type="submit" class="btn btn-primary" onclick="exportDataToRtf()">Export to file for printing</button>
|
||||||
|
<!--[if lte IE 9]>
|
||||||
|
<div>Excel export does not work on IE versions lower than 10. Please use chrome or update IE.</div>
|
||||||
|
<!--<![endif]-->
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div id="exportable">
|
||||||
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %>
|
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %>
|
||||||
<div class="pagebreak">
|
<div class="pagebreak">
|
||||||
<% @weight = w %>
|
<% @weight = w %>
|
||||||
@@ -32,4 +47,5 @@
|
|||||||
<%= render 'fourPoolSemiBracket' %>
|
<%= render 'fourPoolSemiBracket' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
11
db/migrate/20150425173224_matchup_to_match.rb
Normal file
11
db/migrate/20150425173224_matchup_to_match.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
class MatchupToMatch < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :matches, :weight_id, :integer
|
||||||
|
add_column :matches, :bracket_position, :string
|
||||||
|
add_column :matches, :bracket_position_number, :integer
|
||||||
|
rename_column :matches, :r_id, :w1
|
||||||
|
rename_column :matches, :g_id, :w2
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,11 +11,11 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150328183257) do
|
ActiveRecord::Schema.define(version: 20150425173224) do
|
||||||
|
|
||||||
create_table "matches", force: :cascade do |t|
|
create_table "matches", force: :cascade do |t|
|
||||||
t.integer "r_id"
|
t.integer "w1"
|
||||||
t.integer "g_id"
|
t.integer "w2"
|
||||||
t.text "g_stat"
|
t.text "g_stat"
|
||||||
t.text "r_stat"
|
t.text "r_stat"
|
||||||
t.integer "winner_id"
|
t.integer "winner_id"
|
||||||
@@ -27,6 +27,9 @@ ActiveRecord::Schema.define(version: 20150328183257) do
|
|||||||
t.integer "round"
|
t.integer "round"
|
||||||
t.integer "finished"
|
t.integer "finished"
|
||||||
t.integer "boutNumber"
|
t.integer "boutNumber"
|
||||||
|
t.integer "weight_id"
|
||||||
|
t.string "bracket_position"
|
||||||
|
t.integer "bracket_position_number"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "mats", force: :cascade do |t|
|
create_table "mats", force: :cascade do |t|
|
||||||
|
|||||||
Reference in New Issue
Block a user