Add Elo rating system with match entry and CSV upload

- Implement EloCalculator service for 2v2 Euchre matches
- Create background job processing with GoodJob
- Add single match entry form
- Add CSV upload for batch match entry
- Create player rankings view
- Add database schema for matches and elo snapshots
This commit is contained in:
2026-03-26 16:28:24 -07:00
parent 1a9b3496e1
commit 1268889a78
31 changed files with 865 additions and 2 deletions
@@ -0,0 +1,53 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :good_jobs do
primary_key :id
column :queue_name, String
column :priority, Integer, default: 0
column :serialized_params, String
column :scheduled_at, DateTime
column :performed_at, DateTime
column :finished_at, DateTime
column :error, String
column :created_at, DateTime, null: false
column :updated_at, DateTime, null: false
column :active_job_id, String
column :concurrency_key, String
column :sequence, Integer
column :executions_count, Integer
column :job_class, String
column :error_event, Integer
column :labels, String
column :locked_by_id, String
column :locked_at, DateTime
end
add_index :good_jobs, [:scheduled_at, :priority, :id], name: "index_good_jobs_on_scheduled_at"
create_table :good_job_processes do
primary_key :id
column :state, String
column :started_at, DateTime
column :singleton_key, String
column :created_at, DateTime, null: false
column :updated_at, DateTime, null: false
end
create_table :good_job_execution_errors do
primary_key :id
column :active_job_id, String
column :error, String
column :created_at, DateTime, null: false
end
create_table :good_job_settings do
primary_key :id
column :key, String
column :value, String
column :created_at, DateTime, null: false
column :updated_at, DateTime, null: false
end
end
end
@@ -0,0 +1,42 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
# Drop and recreate matches table with new structure
drop_table?(:matches)
create_table :matches do
primary_key :id
foreign_key :event_id, :events
column :played_at, DateTime
column :team_1_p1_id, Integer
column :team_1_p2_id, Integer
column :team_2_p1_id, Integer
column :team_2_p2_id, Integer
column :team_1_score, Integer
column :team_2_score, Integer
column :status, String, default: 'completed'
end
# Add current_elo to players table
alter_table :players do
add_column :current_elo, Integer, default: 1000
end
# Create elo_snapshots table
create_table :elo_snapshots do
primary_key :id
foreign_key :player_id, :players, null: false
foreign_key :match_id, :matches, null: false
column :rating_before, Integer, null: false
column :rating_after, Integer, null: false
column :rating_change, Integer, null: false
column :created_at, DateTime, null: false, default: Sequel::CURRENT_TIMESTAMP
end
# Add indexes for performance
add_index :elo_snapshots, [:player_id, :match_id], unique: true
add_index :matches, :played_at
add_index :matches, :status
end
end