<commit_before>class Live < ApplicationRecord
  has_many :songs, dependent: :restrict_with_exception

  before_save :publish_past_live

  validates :name, presence: true, uniqueness: { scope: :date }
  validates :date, presence: true
  validates :album_url, format: /\A#{URI.regexp(%w[http https])}\z/, allow_blank: true

  scope :order_by_date, -> { order(date: :desc) }
  scope :nendo, ->(year) { where(date: Date.new(year, 4, 1)...Date.new(year + 1, 4, 1)) }
  scope :drafts, -> { where(published: false) }
  scope :published, -> { where(published: true) }

  def self.years
    order_by_date.pluck(:date).map(&:nendo).uniq
  end

  def title
    "#{date.year} #{name}"
  end

  def nf?
    name.include?('NF')
  end

  def publish
    update(published: true, published_at: Time.zone.now)
    songs.includes(:playings).import
  end

  private<commit_msg>Fix Live.years<commit_after>class Live < ApplicationRecord
  has_many :songs, dependent: :restrict_with_exception

  before_save :publish_past_live

  validates :name, presence: true, uniqueness: { scope: :date }
  validates :date, presence: true
  validates :album_url, format: /\A#{URI.regexp(%w[http https])}\z/, allow_blank: true

  scope :order_by_date, -> { order(date: :desc) }
  scope :nendo, ->(year) { where(date: Date.new(year, 4, 1)...Date.new(year + 1, 4, 1)) }
  scope :drafts, -> { where(published: false) }
  scope :published, -> { where(published: true) }

  def self.years
    published.order_by_date.pluck(:date).map(&:nendo).uniq
  end

  def title
    "#{date.year} #{name}"
  end

  def nf?
    name.include?('NF')
  end

  def publish
    update(published: true, published_at: Time.zone.now)
    songs.includes(:playings).import
  end

  private
{'fraction_non_alphanumeric': 0.15304347826086956, 'fraction_numerical': 0.005797101449275362, 'mean_word_length': 3.9314285714285715, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '871905', 'n_tokens_mistral': 637, 'n_tokens_neox': 605, 'n_words': 142}