app/controllers/api/v1/records_controller.rb
# Returns a JSON-encoded Hash of all the IndividualRecord found, filtered by
# Swimmer#id and collected by looping on all MeetingIndividualResult.
#
# The returned rows will be the best results obtained by the specified swimmer_id and
# categorized in the RecordCollection as 'generic' records (code: 'FOR').
#
# Each array element is a JSON-encoded hash of a single row of IndividualRecord.
# The keys of the Hash are the attributes as string.
#
# === Required params:
# - 'id': the matching Swimmer#id
#
Returns a JSON-encoded Hash of all the IndividualRecord found, filtered by
Swimmer#id and collected by looping on all MeetingIndividualResult.

The returned rows will be the best results obtained by the specified swimmer_id and
categorized in the RecordCollection as 'generic' records (code: 'FOR').

Each array element is a JSON-encoded hash of a single row of IndividualRecord.
The keys of the Hash are the attributes as string.

Required params:
'id': the matching Swimmer#id
Returns a JSON - encoded Hash of all the IndividualRecord found filtered by Swimmer#id and collected by looping on all MeetingIndividualResult . The returned rows will be the best results obtained by the specified swimmer_id and categorized in the RecordCollection as ' generic ' records ( code : ' FOR ' ) . Each array element is a JSON - encoded hash of a single row of IndividualRecord . The keys of the Hash are the attributes as string . Required params : ' id ' : the matching Swimmer#id
def for_swimmer
    if params[:id] && (swimmer = Swimmer.find_by_id(params[:id]))
      collector = RecordCollector.new( swimmer: swimmer )
      collection = collector.full_scan do |this, pool_code, event_code, category_code, gender_code|
        this.collect_from_results_having( pool_code, event_code, category_code, gender_code, 'FOR' )
      end
      @records = collection.map{ |key, row| row }
    end
    render status: 200, json: ( @records ? @records : [] )
  end
def for_swimmer if params [ :id ] && ( swimmer = Swimmer . find_by_id ( params [ :id ] ) ) collector = RecordCollector . new ( swimmer : swimmer ) collection = collector . full_scan do | this , pool_code , event_code , category_code , gender_code | this . collect_from_results_having ( pool_code , event_code , category_code , gender_code , 'FOR' ) end @records = collection . map { | key , row | row } end render status : 200 , json : ( @records ? @records : [ ] ) end
Returns a JSON-encoded Hash of all the IndividualRecord found, filtered by
Swimmer#id and collected by looping on all MeetingIndividualResult.
Returns a JSON - encoded Hash of all the IndividualRecord found filtered by Swimmer#id and collected by looping on all MeetingIndividualResult .
# Return just the list of rows: