Introduce architettura multi-sport con catalogo, engine scoring e overlay.

Catalogo sport in YAML, board implicito, engine per volley/basket/timed/racket/timer/generic, regia e app Android allineate.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-09 20:11:21 +02:00
parent 53f9a6a884
commit e727069d43
56 changed files with 1783 additions and 223 deletions

View File

@@ -12,8 +12,12 @@ class Team < ApplicationRecord
has_one_attached :photo_file
validates :name, presence: true
validates :sport_key, presence: true
validate :sport_key_known
validate :photo_file_type, if: -> { photo_file.attached? }
before_validation :normalize_sport_key
def subscription
club.subscription
end
@@ -43,8 +47,35 @@ class Team < ApplicationRecord
end
end
def sport_label
Sports::Catalog.find_optional(sport_key)&.dig(:label) || sport_key.to_s.humanize
end
def effective_board_type
Sports::Catalog.board_for(sport_key)
end
def sport
sport_key
end
def sport=(value)
self.sport_key = Sports::Catalog.normalize_key(value)
end
private
def normalize_sport_key
self.sport_key = Sports::Catalog.normalize_key(sport_key) if sport_key.present?
end
def sport_key_known
return if sport_key.blank?
return if Sports::Catalog.find_optional(sport_key)
errors.add(:sport_key, "non valido")
end
def photo_file_type
return if photo_file.content_type.in?(%w[image/png image/jpeg image/webp])