module Concerns::Event::Dates::ClassMethods

Public Instance Methods

find_all_years() click to toggle source

Return list of every year that has at least one event

# File app/models/concerns/event/dates.rb, line 8
def find_all_years
  years = [ RacingAssociation.current.effective_year ] +
  connection.select_values(
    "select distinct extract(year from date) from events"
  ).map(&:to_i)
  years = years.uniq.sort

  if years.size == 1
    years
  else
    ((years.first)..(years.last)).to_a.reverse
  end
end