app/strategies/team_supermaster_calculator.rb
# Organize swimmer results in a dao
# Consider only max num_events results for score calculation
# A swimmer is included in team score if num_events valid events swam
#
Organize swimmer results in a dao
Consider only max num_events results for score calculation
A swimmer is included in team score if num_events valid events swam
Organize swimmer results in a dao Consider only max num_events results for score calculation A swimmer is included in team score if num_events valid events swam
def parse_swimmer_results( num_events = 3 )
    swimmer_count = 0
    get_swimmer_results if !@got_swimmer_results
    if @swimmer_results.size > 0
      prev_swimmer_id = @swimmer_results[0].swimmer_id
      sts = SupermasterTeamSwimmerDAO.new( prev_swimmer_id )
      sts.set_swimmer_data( @swimmer_results[0].complete_name, @swimmer_results[0].category_code )
      @swimmer_results.each do |swimmer_result|
        if swimmer_result.swimmer_id != prev_swimmer_id
          @team_supermaster_dao << sts
          swimmer_count += 1
          prev_swimmer_id = swimmer_result.swimmer_id
          sts = SupermasterTeamSwimmerDAO.new( swimmer_result.swimmer_id )
          sts.set_swimmer_data( swimmer_result.complete_name, swimmer_result.category_code )
        end
        if sts.get_results_count < num_events
          details = extract_event_detail( swimmer_result.event_detail )
          if sts.add_result_detail( details[:meeting_id], details[:scheduled_date], swimmer_result.event_code, details[:time_swam], swimmer_result.standard_points ) == num_events
            @full_events_swimmers += 1
          end
        end
      end
      @team_supermaster_dao << sts
      swimmer_count += 1
    end
    swimmer_count
  end
def parse_swimmer_results ( num_events = 3 ) swimmer_count = 0 get_swimmer_results if ! @got_swimmer_results if @swimmer_results . size > 0 prev_swimmer_id = @swimmer_results [ 0 ] . swimmer_id sts = SupermasterTeamSwimmerDAO . new ( prev_swimmer_id ) sts . set_swimmer_data ( @swimmer_results [ 0 ] . complete_name , @swimmer_results [ 0 ] . category_code ) @swimmer_results . each do | swimmer_result | if swimmer_result . swimmer_id != prev_swimmer_id @team_supermaster_dao << sts swimmer_count += 1 prev_swimmer_id = swimmer_result . swimmer_id sts = SupermasterTeamSwimmerDAO . new ( swimmer_result . swimmer_id ) sts . set_swimmer_data ( swimmer_result . complete_name , swimmer_result . category_code ) end if sts . get_results_count < num_events details = extract_event_detail ( swimmer_result . event_detail ) if sts . add_result_detail ( details [ :meeting_id ] , details [ :scheduled_date ] , swimmer_result . event_code , details [ :time_swam ] , swimmer_result . standard_points ) == num_events @full_events_swimmers += 1 end end end @team_supermaster_dao << sts swimmer_count += 1 end swimmer_count end
Organize swimmer results in a dao
Consider only max num_events results for score calculation
A swimmer is included in team score if num_events valid events swam
Organize swimmer results in a dao Consider only max num_events results for score calculation A swimmer is included in team score if num_events valid events swam
# Collect swimmer datas # Creates new swimmer element # Checks if max event number has been reached # Adds event result details # Collect last swimmer
num_events
<not_specific>