mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Revert "Moving away from matchups_array and saving matches individually"
This reverts commit 650a9ed7d6.
This commit is contained in:
@@ -2,13 +2,4 @@ class Match < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
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
|
||||
|
||||
@@ -9,13 +9,12 @@ class Tournament < ActiveRecord::Base
|
||||
|
||||
def upcomingMatches
|
||||
# @matches = generateMatchups
|
||||
if self.matches.nil?
|
||||
return self.matches
|
||||
if self.matchups_array
|
||||
return matchupHashesToObjects(self.matchups_array)
|
||||
else
|
||||
@matches = generateMatchups
|
||||
puts @matches.inspect
|
||||
saveMatchups(@matches)
|
||||
return @matches
|
||||
saveMatchups(@matches)
|
||||
return @matches
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,18 +34,8 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def saveMatchups(matches)
|
||||
matches.each do |m|
|
||||
@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
|
||||
self.matchups_array = matchupObjectsToHash(matches)
|
||||
self.save
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,5 @@
|
||||
<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://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>
|
||||
|
||||
@@ -3,26 +3,11 @@
|
||||
#html, #body, #wrapper { width:100%; }
|
||||
|
||||
</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}" %>
|
||||
<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| %>
|
||||
<div class="pagebreak">
|
||||
<% @weight = w %>
|
||||
@@ -47,5 +32,4 @@
|
||||
<%= render 'fourPoolSemiBracket' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,11 +0,0 @@
|
||||
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.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150425173224) do
|
||||
ActiveRecord::Schema.define(version: 20150328183257) do
|
||||
|
||||
create_table "matches", force: :cascade do |t|
|
||||
t.integer "w1"
|
||||
t.integer "w2"
|
||||
t.integer "r_id"
|
||||
t.integer "g_id"
|
||||
t.text "g_stat"
|
||||
t.text "r_stat"
|
||||
t.integer "winner_id"
|
||||
@@ -27,9 +27,6 @@ ActiveRecord::Schema.define(version: 20150425173224) do
|
||||
t.integer "round"
|
||||
t.integer "finished"
|
||||
t.integer "boutNumber"
|
||||
t.integer "weight_id"
|
||||
t.string "bracket_position"
|
||||
t.integer "bracket_position_number"
|
||||
end
|
||||
|
||||
create_table "mats", force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user