ac858f1e6d
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
31 lines
783 B
Ruby
31 lines
783 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rom-repository'
|
|
|
|
module EuchreCamp
|
|
module Repositories
|
|
class PartnershipGames < ::EuchreCamp::Repository[:partnership_games]
|
|
commands :create, update: :by_pk, delete: :by_pk
|
|
|
|
def by_player(player_id)
|
|
partnership_games.where(
|
|
Sequel.|({ player_1_id: player_id }, { player_2_id: player_id })
|
|
).to_a
|
|
end
|
|
|
|
def by_match(match_id)
|
|
partnership_games.where(match_id: match_id).to_a
|
|
end
|
|
|
|
def by_partnership(player_1_id, player_2_id)
|
|
partnership_games.where(
|
|
Sequel.|(
|
|
{ player_1_id: player_1_id, player_2_id: player_2_id },
|
|
{ player_1_id: player_2_id, player_2_id: player_1_id }
|
|
)
|
|
).to_a
|
|
end
|
|
end
|
|
end
|
|
end
|