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
35 lines
1.0 KiB
Ruby
35 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module EuchreCamp
|
|
module Actions
|
|
module Admin
|
|
module Tournaments
|
|
class Create < EuchreCamp::Action
|
|
include Deps[repo: 'repositories.events']
|
|
|
|
def handle(request, response)
|
|
params = request.params.to_h
|
|
|
|
event_params = {
|
|
name: params[:name],
|
|
description: params[:description],
|
|
event_date: params[:event_date] ? Time.parse(params[:event_date]) : nil,
|
|
event_type: 'tournament',
|
|
format: params[:format] || 'single_elim',
|
|
status: 'planned',
|
|
max_participants: params[:max_participants]&.to_i
|
|
}
|
|
|
|
event = repo.create(event_params)
|
|
|
|
response.redirect_to("/admin/tournaments/#{event[:id]}")
|
|
rescue StandardError => e
|
|
response.flash[:error] = "Failed to create tournament: #{e.message}"
|
|
response.redirect_to("/admin/tournaments/new")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|