<commit_before>class Event < ActiveRecord::Base
  include FriendlyIdAble

  paginates_per 12

  has_one :attendance_list, as: :attendable, dependent: :destroy
  has_many :attendances, through: :attendance_list
  has_one :report, dependent: :destroy
  belongs_to :club_team,  class_name: 'Team'
  belongs_to :rival_team, class_name: 'Team'

  accepts_nested_attributes_for :attendance_list

  validates :address,
            :datetime,
            :name,
            :type,
            presence: true

  scope :future, lambda { |limit = nil|
    where('datetime >= ?', Time.zone.now).order('datetime ASC').limit(limit)
  }
  scope :past, lambda { |limit = nil|
    where('datetime < ?', Time.zone.now).order('datetime DESC').limit(limit)
  }

  delegate :future?, :past?, to: :datetime
  delegate :name, to: :club_team, prefix: true
  delegate :name, to: :rival_team, prefix: true
  delegate :open?, to: :attendance_list, prefix: true, allow_nil: true
  delegate :player_pass_needed?, to: :club_team
  delegate :final_score, :lost?, :won?, to: :report, allow_nil: true
<commit_msg>order future Events DESC by datetime<commit_after>class Event < ActiveRecord::Base
  include FriendlyIdAble

  paginates_per 12

  has_one :attendance_list, as: :attendable, dependent: :destroy
  has_many :attendances, through: :attendance_list
  has_one :report, dependent: :destroy
  belongs_to :club_team,  class_name: 'Team'
  belongs_to :rival_team, class_name: 'Team'

  accepts_nested_attributes_for :attendance_list

  validates :address,
            :datetime,
            :name,
            :type,
            presence: true

  scope :future, lambda { |limit = nil|
    where('datetime >= ?', Time.zone.now).order('datetime DESC').limit(limit)
  }
  scope :past, lambda { |limit = nil|
    where('datetime < ?', Time.zone.now).order('datetime DESC').limit(limit)
  }

  delegate :future?, :past?, to: :datetime
  delegate :name, to: :club_team, prefix: true
  delegate :name, to: :rival_team, prefix: true
  delegate :open?, to: :attendance_list, prefix: true, allow_nil: true
  delegate :player_pass_needed?, to: :club_team
  delegate :final_score, :lost?, :won?, to: :report, allow_nil: true

{'fraction_non_alphanumeric': 0.12454212454212454, 'fraction_numerical': 0.0018315018315018315, 'mean_word_length': 4.105140186915888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6856209', 'n_tokens_mistral': 727, 'n_tokens_neox': 713, 'n_words': 187}