| Class | Ironman |
| In: |
app/models/competitions/ironman.rb
|
| Parent: | Competition |
Who has done the most events? Just counts starts/appearences in results. Not pefect — some events are probably over-counted.
# File app/models/competitions/ironman.rb, line 8
8: def Ironman.years
9: years = []
10: results = connection.select_all(
11: "select distinct extract(year from date) as year from events where type = 'Ironman'"
12: )
13: results.each do |year|
14: years << year.values.first.to_i
15: end
16: years.sort.reverse
17: end
# File app/models/competitions/ironman.rb, line 27
27: def source_results(race)
28: Result.find_by_sql(
29: %Q{SELECT results.* FROM results
30: LEFT OUTER JOIN races ON races.id = results.race_id
31: LEFT OUTER JOIN events ON races.event_id = events.id
32: WHERE (place != 'DNS'
33: and races.category_id is not null
34: and (events.type = 'SingleDayEvent' or events.type is null)
35: and events.ironman = true
36: and events.date >= '#{year}-01-01'
37: and events.date <= '#{year}-12-31')
38: ORDER BY person_id}
39: )
40: end