Allinea hub partite app nativa e API match al wizard semplificato.

Filtra le partite visibili lato client/server, corregge il parsing date Rails su Android, semplifica lo step Partita del wizard e restringe l'API ai campi effettivamente usati (campionato, set e scoring_rules).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-07 10:49:30 +02:00
parent f3ff657fc2
commit 08e800120a
16 changed files with 552 additions and 176 deletions

View File

@@ -8,6 +8,7 @@ module Api
matches = @team.matches
.includes(:team, :stream_sessions)
.order(Arel.sql("scheduled_at ASC NULLS LAST"), created_at: :desc)
.select(&:coach_hub_visible?)
render json: matches.map { |m| match_json(m) }
end
@@ -21,7 +22,9 @@ module Api
end
def update
@match.update!(match_params)
attrs = match_params.to_h
normalize_scoring_rules!(attrs)
@match.update!(attrs)
render json: match_json(@match)
end
@@ -52,11 +55,19 @@ module Api
def match_params
params.require(:match).permit(
:opponent_name, :location, :scheduled_at, :sport, :sets_to_win,
:category, :phase, roster_numbers: [],
:category,
scoring_rules: %i[points_per_set points_deciding_set min_point_lead]
)
end
# Regolamento standard: scoring_rules assente o {} → default FIPAV lato Scoring::Rules.
def normalize_scoring_rules!(attrs)
return unless attrs.key?("scoring_rules")
rules = attrs["scoring_rules"]
attrs["scoring_rules"] = {} if rules.blank?
end
def match_json(match, detail: false)
active = active_session_for(match)
{
@@ -69,11 +80,11 @@ module Api
sport: match.sport,
sets_to_win: match.sets_to_win,
scoring_rules: match.scoring_rules.presence,
roster_numbers: match.roster_numbers,
category: match.category,
phase: match.phase,
active_session_id: active&.id,
active_session_status: active&.status
active_session_status: active&.status,
stream_completed: match.stream_completed?,
coach_hub_visible: match.coach_hub_visible?
}
end