From 963812cb0cd2661ca7a64d060fc77f108bfed6d4 Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 14 Mar 2025 13:23:10 +0100 Subject: [PATCH] Annotate advancing teams that advance from group stage --- app/serializers/tournament_serializer.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/serializers/tournament_serializer.rb b/app/serializers/tournament_serializer.rb index 25582e1..df02e38 100644 --- a/app/serializers/tournament_serializer.rb +++ b/app/serializers/tournament_serializer.rb @@ -4,9 +4,19 @@ class TournamentSerializer < SimpleTournamentSerializer attributes :description, :playoff_teams_amount, :instant_finalists_amount, :intermediate_round_participants_amount has_many :stages - has_many :teams attribute :owner_username do object.owner.username end + + attribute :teams do + adv_teams = object.group_stage ? GroupStageService.get_advancing_teams(object.group_stage) : [] + object.teams.map do |team| + { + id: team.id, + name: team.name, + advancing_from_group_stage: adv_teams.include?(team) + } + end + end end