1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added a mariadb replica watcher to fix replication issues

This commit is contained in:
2025-09-30 16:31:43 -04:00
parent 3e1ae22b6b
commit d0f19e855f
4 changed files with 206 additions and 2 deletions

View File

@@ -2,9 +2,13 @@ class Wrestler < ApplicationRecord
belongs_to :school, touch: true
belongs_to :weight, touch: true
has_one :tournament, through: :weight
has_many :deductedPoints, class_name: "Teampointadjust", dependent: :destroy
## Matches association
# Rails associations expect only a single column so we cannot do a w1 OR w2
# So we have to create two associations and combine them with the all_matches method
has_many :matches_as_w1, ->(wrestler){ where(weight_id: wrestler.weight_id) }, class_name: 'Match', foreign_key: 'w1'
has_many :matches_as_w2, ->(wrestler){ where(weight_id: wrestler.weight_id) }, class_name: 'Match', foreign_key: 'w2'
has_many :deductedPoints, class_name: "Teampointadjust", dependent: :destroy
##
attr_accessor :poolAdvancePoints, :originalId, :swapId
validates :name, :weight_id, :school_id, presence: true