app/controllers/teams_controller.rb
# Prepares the PDF print-out for the event and relay reservations for the current
# meeting.
#
# == Params:
# id: the meeting id to be processed
#
# == Implied parameters:
# current_user:  user must be logged-in and either be a team-manager or have an
#                associated swimmer (must be a "goggler").
#                (when also a team-manager, the whole matrix of rows should be editable)
#
Prepares the PDF print-out for the event and relay reservations for the current
meeting.

the meeting id to be processed

Implied parameters:
current_user:  user must be logged-in and either be a team-manager or have an
associated swimmer (must be a "goggler").
(when also a team-manager, the whole matrix of rows should be editable)
Prepares the PDF print - out for the event and relay reservations for the current meeting . the meeting id to be processed Implied parameters : current_user : user must be logged - in and either be a team - manager or have an associated swimmer ( must be a " goggler " ) . ( when also a team - manager the whole matrix of rows should be editable )
def printout_best_timings
    unless @team.meeting_individual_results.exists?
      flash[:error] = I18n.t('radiography.team.no_data_to_process_for_this_team')
      redirect_to( team_radio_path(id: @team.id) ) and return
    end
    unless IndividualRecord.for_team( @team.id ).exists?
      flash[:error] = I18n.t('radiography.team.no_record_found_for_this_team')
      redirect_to( team_radio_path(id: @team.id) ) and return
        @team_bests = @team_best_finder.split_categories( @team_best_finder.scan_for_distinct_bests )
    end
     Setup the record collection and get the pre-calc records MIRs:
    team_distinct_best_dao = RecordX4dDAO.new( @team, RecordType.find_by_code( 'TTB' ) )
     Scan the pre-computed records and fill the collection DAO with each records'MIR row found:
    IndividualRecord.for_team( @team.id ).includes(:meeting_individual_result)
      .joins(:meeting_individual_result).each do |record|
        team_distinct_best_dao.add_record( record.meeting_individual_result )
    end
    @team_best_finder = TeamBestFinder.new( @team )
    @team_bests = @team_best_finder.split_categories( team_distinct_best_dao )
                                                     == OPTIONS setup + RENDERING phase ==
    base_filename = "{ I18n.t('radiography.team.ttb_records_basefilename') }_{ @team.id }"
    filename = create_unique_filename( base_filename ) + '.pdf'
    options = {
      report_title:         I18n.t('radiography.team.ttb_records_title'),
      meta_info_subject:    'team best-timings records printout',
      meta_info_keywords:   "Goggles, {base_filename}'",
      team:                 @team,
      team_best_finder:     @team_best_finder,
      team_bests:           @team_bests
    }
    send_data(                                       == Render layout & send data:
        TeamBestTimingsLayout.render( options ),
        type: 'application/pdf',
        filename: filename
    )
  end
def printout_best_timings unless @team . meeting_individual_results . exists? flash [ :error ] = I18n . t ( 'radiography.team.no_data_to_process_for_this_team' ) redirect_to ( team_radio_path ( id : @team . id ) ) and return end unless IndividualRecord . for_team ( @team . id ) . exists? flash [ :error ] = I18n . t ( 'radiography.team.no_record_found_for_this_team' ) redirect_to ( team_radio_path ( id : @team . id ) ) and return end team_distinct_best_dao = RecordX4dDAO . new ( @team , RecordType . find_by_code ( 'TTB' ) ) IndividualRecord . for_team ( @team . id ) . includes ( :meeting_individual_result ) . joins ( :meeting_individual_result ) . each do | record | team_distinct_best_dao . add_record ( record . meeting_individual_result ) end @team_best_finder = TeamBestFinder . new ( @team ) @team_bests = @team_best_finder . split_categories ( team_distinct_best_dao ) base_filename = "#{ I18n.t('radiography.team.ttb_records_basefilename') }_#{ @team.id }" filename = create_unique_filename ( base_filename ) + '.pdf' options = { report_title : I18n . t ( 'radiography.team.ttb_records_title' ) , meta_info_subject : 'team best-timings records printout' , meta_info_keywords : "Goggles, #{base_filename}'" , team : @team , team_best_finder : @team_best_finder , team_bests : @team_bests } send_data ( TeamBestTimingsLayout . render ( options ) , type : 'application/pdf' , filename : filename ) end
Prepares the PDF print-out for the event and relay reservations for the current
meeting.
Prepares the PDF print - out for the event and relay reservations for the current meeting .
# Bail out in case there are no results to process: # Bail out in case there are no best-timings to process: # TODO / FUTURE DEV [Steve, 20170413] Eventually, it could be possibile to fall-back # to a real-time computation of the team's best timings, using the same # (OLD) implementation from the above action: # #  @team_bests = @team_best_finder.split_categories( @team_best_finder.scan_for_distinct_bests ) # Setup the record collection and get the pre-calc records MIRs: # Scan the pre-computed records and fill the collection DAO with each records'MIR row found: # == OPTIONS setup + RENDERING phase == # == Render layout & send data: