@@ -17,7 +17,7 @@ class LobbyController < Api::V1::BaseController
1717 def index
1818 scrims = Scrim . unscoped
1919 . eager_load ( :organization )
20- . includes ( :opponent_team )
20+ . includes ( :opponent_team , organization : :players )
2121 . where ( scrims : { visibility : 'public' } )
2222 . where ( organizations : { is_public : true } )
2323 . where ( 'scrims.scheduled_at >= ?' , Time . current )
@@ -69,10 +69,28 @@ def serialize_lobby_scrim(scrim)
6969 region : org . region ,
7070 tier : org . try ( :tier ) ,
7171 public_tagline : org . try ( :public_tagline ) ,
72- discord_invite_url : org . try ( :discord_invite_url )
72+ discord_invite_url : org . try ( :discord_invite_url ) ,
73+ roster : serialize_org_roster ( org )
7374 }
7475 }
7576 end
77+
78+ # Returns the org's active players sorted by role, already preloaded via includes.
79+ # Capped at 10 to keep the response lean.
80+ def serialize_org_roster ( org )
81+ role_sort = %w[ top jungle mid adc support ]
82+ players = org . players . select ( &:active? )
83+ players . sort_by { |p | [ role_sort . index ( p . role ) || 99 , p . summoner_name ] }
84+ . first ( 10 )
85+ . map do |p |
86+ {
87+ summoner_name : p . summoner_name ,
88+ role : p . role ,
89+ tier : p . solo_queue_tier ,
90+ tier_rank : p . solo_queue_rank
91+ }
92+ end
93+ end
7694 end
7795 end
7896end
0 commit comments