feat(tournaments): add partnership tracking and tournament management
Implement comprehensive partnership tracking system and tournament management features including round-robin, single/double elimination, and Swiss system pairings. Changes: - Add partnership_games and partnership_stats tables - Implement PartnershipTracker service for recording partnership data - Add tournament generator with multiple formats - Create tournament management actions and views - Add acceptance tests for partnership tracking - Fix PartnershipTracker to use single snapshot per player per match - Fix round-robin test to query by round_number instead of hardcoded ID Note: All 8 acceptance tests now passing
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class BracketMatchups < ROM::Relation[:sql]
|
||||
schema(:bracket_matchups, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :event_id, ROM::Types::Integer
|
||||
attribute :round_id, ROM::Types::Integer
|
||||
attribute :match_id, ROM::Types::Integer.optional
|
||||
attribute :team_1_id, ROM::Types::Integer.optional
|
||||
attribute :team_2_id, ROM::Types::Integer.optional
|
||||
attribute :bracket_position, ROM::Types::Integer.optional
|
||||
attribute :winner_team_id, ROM::Types::Integer.optional
|
||||
attribute :loser_team_id, ROM::Types::Integer.optional
|
||||
|
||||
associations do
|
||||
belongs_to :event
|
||||
belongs_to :round, relation: :tournament_rounds
|
||||
belongs_to :match
|
||||
belongs_to :team_1, relation: :teams
|
||||
belongs_to :team_2, relation: :teams
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class EventParticipants < ROM::Relation[:sql]
|
||||
schema(:event_participants, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :event_id, ROM::Types::Integer
|
||||
attribute :player_id, ROM::Types::Integer
|
||||
attribute :team_id, ROM::Types::Integer.optional
|
||||
attribute :status, ROM::Types::String.default('registered')
|
||||
attribute :seed, ROM::Types::Integer.optional
|
||||
attribute :registration_date, ROM::Types::DateTime
|
||||
|
||||
associations do
|
||||
belongs_to :event
|
||||
belongs_to :player
|
||||
belongs_to :team
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class Events < ROM::Relation[:sql]
|
||||
schema(:events, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :event_id, ROM::Types::Integer.optional
|
||||
attribute :name, ROM::Types::String
|
||||
attribute :description, ROM::Types::String.optional
|
||||
attribute :event_date, ROM::Types::DateTime.optional
|
||||
attribute :event_type, ROM::Types::String.default('tournament')
|
||||
attribute :format, ROM::Types::String.default('single_elim')
|
||||
attribute :status, ROM::Types::String.default('planned')
|
||||
attribute :max_participants, ROM::Types::Integer.optional
|
||||
attribute :created_at, ROM::Types::DateTime
|
||||
attribute :updated_at, ROM::Types::DateTime
|
||||
|
||||
associations do
|
||||
has_many :event_participants
|
||||
has_many :teams
|
||||
has_many :tournament_rounds
|
||||
has_many :bracket_matchups
|
||||
has_many :matches
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class PartnershipGames < ROM::Relation[:sql]
|
||||
schema(:partnership_games, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :match_id, ROM::Types::Integer
|
||||
attribute :player_1_id, ROM::Types::Integer
|
||||
attribute :player_2_id, ROM::Types::Integer
|
||||
attribute :team_number, ROM::Types::Integer
|
||||
attribute :won_match, ROM::Types::Integer
|
||||
attribute :created_at, ROM::Types::DateTime
|
||||
|
||||
associations do
|
||||
belongs_to :match
|
||||
belongs_to :player_1, relation: :players, foreign_key: :player_1_id
|
||||
belongs_to :player_2, relation: :players, foreign_key: :player_2_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class PartnershipStats < ROM::Relation[:sql]
|
||||
schema(:partnership_stats, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :player_1_id, ROM::Types::Integer
|
||||
attribute :player_2_id, ROM::Types::Integer
|
||||
attribute :games_played, ROM::Types::Integer.default(0)
|
||||
attribute :wins, ROM::Types::Integer.default(0)
|
||||
attribute :losses, ROM::Types::Integer.default(0)
|
||||
attribute :total_elo_change, ROM::Types::Integer.default(0)
|
||||
attribute :last_played, ROM::Types::DateTime.optional
|
||||
attribute :created_at, ROM::Types::DateTime
|
||||
attribute :updated_at, ROM::Types::DateTime
|
||||
|
||||
associations do
|
||||
belongs_to :player_1, relation: :players, foreign_key: :player_1_id
|
||||
belongs_to :player_2, relation: :players, foreign_key: :player_2_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class Teams < ROM::Relation[:sql]
|
||||
schema(:teams, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :event_id, ROM::Types::Integer
|
||||
attribute :team_name, ROM::Types::String.optional
|
||||
attribute :player_1_id, ROM::Types::Integer
|
||||
attribute :player_2_id, ROM::Types::Integer
|
||||
attribute :created_at, ROM::Types::DateTime
|
||||
|
||||
associations do
|
||||
belongs_to :event
|
||||
belongs_to :player_1, relation: :players, foreign_key: :player_1_id
|
||||
belongs_to :player_2, relation: :players, foreign_key: :player_2_id
|
||||
has_many :event_participants
|
||||
has_many :bracket_matchups
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EuchreCamp
|
||||
module Persistence
|
||||
module Relations
|
||||
class TournamentRounds < ROM::Relation[:sql]
|
||||
schema(:tournament_rounds, infer: true) do
|
||||
attribute :id, ROM::Types::Integer, primary_key: true
|
||||
attribute :event_id, ROM::Types::Integer
|
||||
attribute :round_number, ROM::Types::Integer
|
||||
attribute :status, ROM::Types::String.default('pending')
|
||||
attribute :scheduled_start, ROM::Types::DateTime.optional
|
||||
attribute :actual_start, ROM::Types::DateTime.optional
|
||||
attribute :completed_at, ROM::Types::DateTime.optional
|
||||
|
||||
associations do
|
||||
belongs_to :event
|
||||
has_many :bracket_matchups
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user