class RiderRankings

WSBA rider rankings. Members get points for top-10 finishes in any event

Public Instance Methods

create_races() click to toggle source
# File app/models/competitions/rider_rankings.rb, line 13
def create_races
  association_category = Category.find_or_create_by_name(RacingAssociation.current.short_name)
  for category_name in [
    'Junior Men A', 'Junior Men B', 'Junior Men C', 'Junior Men D',
    'Junior Women A', 'Junior Women B', 'Junior Women C', 'Junior Women D',
    'Men Cat 1-2', 'Men Cat 3', 'Men Cat 4-5', 
    'Master Men Cat 1-3', 'Master Men Cat 4-5', 
    'Masters 50+',
    'Masters Women A', 'Masters Women B', 
    'Women Cat 1-2', 'Women Cat 3', 'Women Cat 4']

    category = Category.find_or_create_by_name(category_name)
    unless category.parent
      category.parent = association_category
      category.save!
    end
    self.races.create(:category => category)
  end
end
friendly_name() click to toggle source
# File app/models/competitions/rider_rankings.rb, line 5
def friendly_name
  'Rider Rankings'
end
member?(person, date) click to toggle source
# File app/models/competitions/rider_rankings.rb, line 50
def member?(person, date)
  person && person.member?(date)
end
place_members_only?() click to toggle source
# File app/models/competitions/rider_rankings.rb, line 9
def place_members_only?
  true
end
source_results(race) click to toggle source

#source_results must be in person-order

# File app/models/competitions/rider_rankings.rb, line 34
def source_results(race)
  Result.all(
              :include => [:race, {:person => :team}, :team, {:race => [:event, :category]}],
              :conditions => [%Q{
                members_only_place between 1 AND #{point_schedule.size - 1}
                  and results.person_id is not null
                  and events.type = 'SingleDayEvent' 
                  and events.sanctioned_by = "#{RacingAssociation.current.default_sanctioned_by}"
                  and categories.id in (#{category_ids_for(race).join(", ")})
                  and (races.bar_points > 0 or (races.bar_points is null and events.bar_points > 0))
                  and events.date between '#{date.beginning_of_year}' and '#{date.end_of_year}'
              }],
              :order => 'person_id'
  )
end