mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-07 06:54:16 +00:00
Fixed query for upcoming matches on the bout board and trying to fix why currently generating matches is not nil when
generating a single weight class.
This commit is contained in:
@@ -4,11 +4,11 @@ class TournamentsController < ApplicationController
|
|||||||
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
||||||
before_action :check_tournament_errors, only: [:generate_matches]
|
before_action :check_tournament_errors, only: [:generate_matches]
|
||||||
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
||||||
|
|
||||||
def weigh_in_sheet
|
def weigh_in_sheet
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def swap
|
def swap
|
||||||
@wrestler = Wrestler.find(params[:wrestler][:originalId])
|
@wrestler = Wrestler.find(params[:wrestler][:originalId])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -18,7 +18,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_teampointadjust
|
def remove_teampointadjust
|
||||||
if params[:teampointadjust]
|
if params[:teampointadjust]
|
||||||
@points = Teampointadjust.find(params[:teampointadjust])
|
@points = Teampointadjust.find(params[:teampointadjust])
|
||||||
@@ -28,7 +28,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def teampointadjust
|
def teampointadjust
|
||||||
if params[:teampointadjust]
|
if params[:teampointadjust]
|
||||||
@points = Teampointadjust.new
|
@points = Teampointadjust.new
|
||||||
@@ -46,7 +46,7 @@ class TournamentsController < ApplicationController
|
|||||||
@point_adjustments = @tournament.pointAdjustments
|
@point_adjustments = @tournament.pointAdjustments
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_delegate
|
def remove_delegate
|
||||||
if params[:delegate]
|
if params[:delegate]
|
||||||
@delegate = TournamentDelegate.find(params[:delegate])
|
@delegate = TournamentDelegate.find(params[:delegate])
|
||||||
@@ -56,7 +56,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_school_delegate
|
def remove_school_delegate
|
||||||
if params[:delegate]
|
if params[:delegate]
|
||||||
@delegate = SchoolDelegate.find(params[:delegate])
|
@delegate = SchoolDelegate.find(params[:delegate])
|
||||||
@@ -66,7 +66,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def school_delegate
|
def school_delegate
|
||||||
if params[:search]
|
if params[:search]
|
||||||
@users = User.search(params[:search])
|
@users = User.search(params[:search])
|
||||||
@@ -90,7 +90,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delegate
|
def delegate
|
||||||
if params[:search]
|
if params[:search]
|
||||||
@users = User.search(params[:search])
|
@users = User.search(params[:search])
|
||||||
@@ -109,7 +109,7 @@ class TournamentsController < ApplicationController
|
|||||||
@users_delegates = @tournament.delegates
|
@users_delegates = @tournament.delegates
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches
|
def matches
|
||||||
@matches = @tournament.matches.sort_by{|m| m.bout_number}
|
@matches = @tournament.matches.sort_by{|m| m.bout_number}
|
||||||
if @match
|
if @match
|
||||||
@@ -118,7 +118,7 @@ class TournamentsController < ApplicationController
|
|||||||
@wrestlers = [@w1,@w2]
|
@wrestlers = [@w1,@w2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def weigh_in_weight
|
def weigh_in_weight
|
||||||
if params[:wrestler]
|
if params[:wrestler]
|
||||||
Wrestler.update(params[:wrestler].keys, params[:wrestler].values)
|
Wrestler.update(params[:wrestler].keys, params[:wrestler].values)
|
||||||
@@ -130,7 +130,7 @@ class TournamentsController < ApplicationController
|
|||||||
@weights = @tournament.weights
|
@weights = @tournament.weights
|
||||||
end
|
end
|
||||||
if @weight
|
if @weight
|
||||||
@wrestlers = @weight.wrestlers
|
@wrestlers = @weight.wrestlers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
def all_brackets
|
def all_brackets
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bracket
|
def bracket
|
||||||
@@ -180,9 +180,9 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def up_matches
|
def up_matches
|
||||||
@matches = @tournament.matches.where(mat_id: nil).order('bout_number ASC').limit(10).includes(:wrestlers)
|
@matches = @tournament.matches.where("mat_id is NULL and (finished <> ? or finished is NULL)",1).order('bout_number ASC').limit(10).includes(:wrestlers)
|
||||||
@mats = @tournament.mats.includes(:matches)
|
@mats = @tournament.mats.includes(:matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ class TournamentsController < ApplicationController
|
|||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def error
|
def error
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -257,12 +257,12 @@ class TournamentsController < ApplicationController
|
|||||||
def tournament_params
|
def tournament_params
|
||||||
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId)
|
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId)
|
||||||
end
|
end
|
||||||
|
|
||||||
#Check for tournament owner
|
#Check for tournament owner
|
||||||
def check_access_destroy
|
def check_access_destroy
|
||||||
authorize! :destroy, @tournament
|
authorize! :destroy, @tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_access_manage
|
def check_access_manage
|
||||||
authorize! :manage, @tournament
|
authorize! :manage, @tournament
|
||||||
end
|
end
|
||||||
@@ -274,7 +274,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_tournament_errors
|
def check_tournament_errors
|
||||||
if @tournament.tournamentMatchGenerationError != nil
|
if @tournament.tournamentMatchGenerationError != nil
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -282,5 +282,5 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class GenerateTournamentMatches
|
|||||||
assignBouts
|
assignBouts
|
||||||
assignFirstMatchesToMats
|
assignFirstMatchesToMats
|
||||||
@tournament.curently_generating_matches = nil
|
@tournament.curently_generating_matches = nil
|
||||||
@tournament.save
|
@tournament.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def assignBouts
|
def assignBouts
|
||||||
|
|||||||
Reference in New Issue
Block a user