class Ironman

Who has done the most events? Just counts starts/appearences in results. Not pefect – some events are probably over-counted.

Public Class Methods

years() click to toggle source
# File app/models/competitions/ironman.rb, line 8
def Ironman.years
  years = []
  results = connection.select_all(
    "select distinct extract(year from date) as year from events where type = 'Ironman'"
  )
  results.each do |year|
    years << year.values.first.to_i
  end
  years.sort.reverse
end

Public Instance Methods

break_ties?() click to toggle source
# File app/models/competitions/ironman.rb, line 23
def break_ties?
  false
end
friendly_name() click to toggle source
# File app/models/competitions/ironman.rb, line 4
def friendly_name
  'Ironman'
end
points_for(source_result) click to toggle source
# File app/models/competitions/ironman.rb, line 19
def points_for(source_result)
  1
end
source_results(race) click to toggle source
# File app/models/competitions/ironman.rb, line 27
def source_results(race)
  Result.
    joins(:race, :event).
    where("place != 'DNS'").
    where("races.category_id is not null").
    where("events.type = 'SingleDayEvent' or events.type is null").
    where("events.ironman = true").
    where("results.date between ? and ?", Time.zone.local(year).beginning_of_year, Time.zone.local(year).end_of_year).
    order("person_id")
end