<commit_before># == Schema Information
#
# Table name: events
#
#  id                :integer          not null, primary key
#  name              :string(510)
#  range_from        :integer
#  range_to          :integer
#  created_at        :datetime
#  updated_at        :datetime
#  status            :integer          default("draft")
#  profile_id        :integer
#  place_id          :integer
#  is_official       :boolean
#  rules             :integer          default("speed_distance_time")
#  starts_at         :date
#  wind_cancellation :boolean          default(FALSE)
#  visibility        :integer          default("public_event")
#

class Event < ApplicationRecord
  enum status: [:draft, :published, :finished]
  enum rules: [:speed_distance_time, :fai, :hungary_boogie]
  enum visibility: [:public_event, :unlisted_event, :private_event]

  belongs_to :responsible,
             class_name: 'Profile',
             foreign_key: 'profile_id'

  belongs_to :place, optional: true

  has_many :event_organizers
  has_many :sections, -> { order(:order) }
  has_many :competitors
  has_many :rounds
  has_many :event_tracks, through: :rounds
  has_many :tracks, through: :event_tracks
  has_many :sponsors, -> { order(:created_at) }, as: :sponsorable, dependent: :delete_all
  has_many :weather_data, as: :weather_datumable, dependent: :delete_all

  validates :responsible, :name, :range_from, :range_to, :starts_at, presence: true

  before_validation :check_name_and_range, on: :create
  after_save :set_tracks_visibility, on: :update, if: :saved_change_to_visibility?

  delegate :name, to: :place, prefix: true, allow_nil: true
  delegate :msl, to: :place, prefix: true, allow_nil: true

  after_initialize do
    self.range_from ||= 3000
    self.range_to ||= 2000
  end<commit_msg>Implicitly set order for rounds<commit_after># == Schema Information
#
# Table name: events
#
#  id                :integer          not null, primary key
#  name              :string(510)
#  range_from        :integer
#  range_to          :integer
#  created_at        :datetime
#  updated_at        :datetime
#  status            :integer          default("draft")
#  profile_id        :integer
#  place_id          :integer
#  is_official       :boolean
#  rules             :integer          default("speed_distance_time")
#  starts_at         :date
#  wind_cancellation :boolean          default(FALSE)
#  visibility        :integer          default("public_event")
#

class Event < ApplicationRecord
  enum status: [:draft, :published, :finished]
  enum rules: [:speed_distance_time, :fai, :hungary_boogie]
  enum visibility: [:public_event, :unlisted_event, :private_event]

  belongs_to :responsible,
             class_name: 'Profile',
             foreign_key: 'profile_id'

  belongs_to :place, optional: true

  has_many :event_organizers
  has_many :sections, -> { order(:order) }
  has_many :competitors
  has_many :rounds, -> { order(:name) }
  has_many :event_tracks, through: :rounds
  has_many :tracks, through: :event_tracks
  has_many :sponsors, -> { order(:created_at) }, as: :sponsorable, dependent: :delete_all
  has_many :weather_data, as: :weather_datumable, dependent: :delete_all

  validates :responsible, :name, :range_from, :range_to, :starts_at, presence: true

  before_validation :check_name_and_range, on: :create
  after_save :set_tracks_visibility, on: :update, if: :saved_change_to_visibility?

  delegate :name, to: :place, prefix: true, allow_nil: true
  delegate :msl, to: :place, prefix: true, allow_nil: true

  after_initialize do
    self.range_from ||= 3000
    self.range_to ||= 2000
  end
{'fraction_non_alphanumeric': 0.10245111539520793, 'fraction_numerical': 0.006058936931974662, 'mean_word_length': 3.165137614678899, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '4396983', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1126, 'n_words': 286}