mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Record score in db and update when match is updated
This commit is contained in:
@@ -60,7 +60,7 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
def team_scores
|
def team_scores
|
||||||
@schools = @tournament.schools
|
@schools = @tournament.schools
|
||||||
@schools.sort_by{|s| s.score}
|
@schools.sort_by{|s| s.score}.reverse!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ class Match < ActiveRecord::Base
|
|||||||
after_save do
|
after_save do
|
||||||
if self.finished == 1
|
if self.finished == 1
|
||||||
advance_wrestlers
|
advance_wrestlers
|
||||||
|
self.wrestler1.school.calcScore
|
||||||
|
self.wrestler2.school.calcScore
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ class School < ActiveRecord::Base
|
|||||||
|
|
||||||
|
|
||||||
#calculate score here
|
#calculate score here
|
||||||
def score
|
|
||||||
calcScore
|
|
||||||
end
|
|
||||||
|
|
||||||
def calcScore
|
def calcScore
|
||||||
totalWrestlerPoints - totalDeductedPoints
|
totalWrestlerPoints - totalDeductedPoints
|
||||||
|
|||||||
5
db/migrate/20151117152454_add_score_back_to_school.rb
Normal file
5
db/migrate/20151117152454_add_score_back_to_school.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddScoreBackToSchool < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :schools, :score, :decimal
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# 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: 20151111130227) do
|
ActiveRecord::Schema.define(version: 20151117152454) do
|
||||||
|
|
||||||
create_table "matches", force: :cascade do |t|
|
create_table "matches", force: :cascade do |t|
|
||||||
t.integer "w1"
|
t.integer "w1"
|
||||||
@@ -37,7 +37,7 @@ ActiveRecord::Schema.define(version: 20151111130227) do
|
|||||||
|
|
||||||
add_index "matches", ["mat_id"], name: "index_matches_on_mat_id"
|
add_index "matches", ["mat_id"], name: "index_matches_on_mat_id"
|
||||||
add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id"
|
add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id"
|
||||||
add_index "matches", ["w1", "w2"], name: "index_matches_on_w1_and_w2"
|
add_index "matches", ["w1", "w2"], name: "index_matches_on_w1_and_w2", unique: true
|
||||||
|
|
||||||
create_table "mats", force: :cascade do |t|
|
create_table "mats", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
@@ -53,6 +53,7 @@ ActiveRecord::Schema.define(version: 20151111130227) do
|
|||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "tournament_id"
|
t.integer "tournament_id"
|
||||||
|
t.decimal "score"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "schools", ["tournament_id"], name: "index_schools_on_tournament_id"
|
add_index "schools", ["tournament_id"], name: "index_schools_on_tournament_id"
|
||||||
@@ -79,6 +80,7 @@ ActiveRecord::Schema.define(version: 20151111130227) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
add_index "tournaments", ["user_id"], name: "index_tournaments_on_user_id"
|
add_index "tournaments", ["user_id"], name: "index_tournaments_on_user_id"
|
||||||
|
add_index "tournaments", ["weigh_in_ref"], name: "index_tournaments_on_weigh_in_ref"
|
||||||
|
|
||||||
create_table "users", force: :cascade do |t|
|
create_table "users", force: :cascade do |t|
|
||||||
t.string "email", default: "", null: false
|
t.string "email", default: "", null: false
|
||||||
@@ -122,6 +124,7 @@ ActiveRecord::Schema.define(version: 20151111130227) do
|
|||||||
t.decimal "offical_weight"
|
t.decimal "offical_weight"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "wrestlers", ["offical_weight"], name: "index_wrestlers_on_offical_weight"
|
||||||
add_index "wrestlers", ["weight_id"], name: "index_wrestlers_on_weight_id"
|
add_index "wrestlers", ["weight_id"], name: "index_wrestlers_on_weight_id"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user