app/controllers/meeting_results_controller.rb
# Edit view action for the meeting relay swimmers.
#
# The actual correlated update action is performed via API/v2/remote_edit/ AJAX call.
#
Edit view action for the meeting relay swimmers.
The actual correlated update action is performed via API/v2/remote_edit/ AJAX call.
Edit view action for the meeting relay swimmers . The actual correlated update action is performed via API / v2 / remote_edit / AJAX call .
def edit_relay_swimmers
    @managed_teams = current_user
      .team_managers
      .joins( :team_affiliation )
      .where( ['team_affiliations.season_id = ?', @meeting.season_id] )
      .map{ |tm| tm.team }
      .uniq
    @managed_team_ids = @managed_teams.map{ |team| team.id }
    @mrrs = @meeting.meeting_relay_results
      .includes(:team, :meeting_event, :event_type, :pool_type, :season)
      .joins(:team, :meeting_event, :event_type, :pool_type, :season)
      .where( ['team_id IN (?)', @managed_team_ids] )
    @relay_swimmer_hash = {}
    @mrrs.each do |mrr|
      needed_swimmer_count = mrr.event_type.partecipants
      relay_swimmers = []
      ( 1 .. needed_swimmer_count ).each do |index|
        existing_relay_swimmer = MeetingRelaySwimmer.where( meeting_relay_result_id: mrr.id, relay_order: index ).first
        relay_swimmers << (
          existing_relay_swimmer ||
          MeetingRelaySwimmer.new(
            meeting_relay_result_id: mrr.id,
            relay_order:             index,
            stroke_type_id:          RelaySwimmerUpdater.get_fractionist_stroke_type_id_by( mrr.event_type.stroke_type_id, index )
          )
        )
      end
      @relay_swimmer_hash[ mrr.id ] = relay_swimmers
    end
  end
def edit_relay_swimmers @managed_teams = current_user . team_managers . joins ( :team_affiliation ) . where ( [ 'team_affiliations.season_id = ?' , @meeting . season_id ] ) . map { | tm | tm . team } . uniq @managed_team_ids = @managed_teams . map { | team | team . id } @mrrs = @meeting . meeting_relay_results . includes ( :team , :meeting_event , :event_type , :pool_type , :season ) . joins ( :team , :meeting_event , :event_type , :pool_type , :season ) . where ( [ 'team_id IN (?)' , @managed_team_ids ] ) @relay_swimmer_hash = { } @mrrs . each do | mrr | needed_swimmer_count = mrr . event_type . partecipants relay_swimmers = [ ] ( 1 .. needed_swimmer_count ) . each do | index | existing_relay_swimmer = MeetingRelaySwimmer . where ( meeting_relay_result_id : mrr . id , relay_order : index ) . first relay_swimmers << ( existing_relay_swimmer || MeetingRelaySwimmer . new ( meeting_relay_result_id : mrr . id , relay_order : index , stroke_type_id : RelaySwimmerUpdater . get_fractionist_stroke_type_id_by ( mrr . event_type . stroke_type_id , index ) ) ) end @relay_swimmer_hash [ mrr . id ] = relay_swimmers end end
Edit view action for the meeting relay swimmers.
Edit view action for the meeting relay swimmers .
# Collect the list of managed Teams: # Leega: Managed teams are always referred to the meeting season  #@managed_teams = current_user.team_managers.map{ |tm| tm.team }.uniq # Fill-in the relay swimmers either with new instances or with existing ones: # Add the completed list of relay swimmers to the hash, for each existing MRR: