<commit_before>class Event < ActiveRecord::Base
  include ApplicationProcess::Validator
  has_many :applications, dependent: :destroy

  validates :organizer_name, :description, :name, :website, :code_of_conduct, :city, :country, presence: true
  validates :start_date, :deadline, date: true, presence: true
  validates :end_date, date: { after_or_equal_to: :start_date }, presence: true
  validates :organizer_email, confirmation: true, format: { with: /.+@.+\..+/ }, presence: true
  validates :organizer_email_confirmation, presence: true, on: :create
  validates :website, :code_of_conduct, format: { with: /(http|https):\/\/.+\..+/ }
  validates :number_of_tickets, numericality: { only_integer: true, greater_than_or_equal_to: 1 }, presence: true

  def self.approved
    where(approved: true)
  end

  def self.unapproved
    where(approved: false)
  end

  def self.upcoming(now = DateTime.now)
    where('end_date >= ?', now)
  end

  def self.past(now = DateTime.now)
    where('end_date < ?', now)
  end

  def self.open(now = DateTime.now)
    where('deadline >= ?', now)
  end

  def self.closed(now = DateTime.now)
    where('deadline < ?', now)
  end

  def open?
    deadline_as_time >= Time.now
  end

  def closed?
    deadline_as_time < Time.now
  end

  def deadline_as_time
    (deadline + 1).in_time_zone("UTC")
  end

  def to_csv
    CSV.generate do |csv|
      csv << ["Name", "Email", "Why do you want to attend #{self.name} and what especially do you look forward to learning?", "Please share with us why you're applying for a diversity ticket."]
      applications.each do |application|
        csv << [application.name, application.email, application.attendee_info_1, application.attendee_info_2]
      end
    end
  end
end<commit_msg>add class method that retrieves events with deadline two days from now from DB<commit_after>class Event < ActiveRecord::Base
  include ApplicationProcess::Validator
  has_many :applications, dependent: :destroy

  validates :organizer_name, :description, :name, :website, :code_of_conduct, :city, :country, presence: true
  validates :start_date, :deadline, date: true, presence: true
  validates :end_date, date: { after_or_equal_to: :start_date }, presence: true
  validates :organizer_email, confirmation: true, format: { with: /.+@.+\..+/ }, presence: true
  validates :organizer_email_confirmation, presence: true, on: :create
  validates :website, :code_of_conduct, format: { with: /(http|https):\/\/.+\..+/ }
  validates :number_of_tickets, numericality: { only_integer: true, greater_than_or_equal_to: 1 }, presence: true

  def self.approved
    where(approved: true)
  end

  def self.unapproved
    where(approved: false)
  end

  def self.upcoming(now = DateTime.now)
    where('end_date >= ?', now)
  end

  def self.past(now = DateTime.now)
    where('end_date < ?', now)
  end

  def self.open(now = DateTime.now)
    where('deadline >= ?', now)
  end

  def self.closed(now = DateTime.now)
    where('deadline < ?', now)
  end

  def self.deadline_in_two_days(now = DateTime.now)
    where('deadline = ?', now + 2.days)
  end

  def open?
    deadline_as_time >= Time.now
  end

  def closed?
    deadline_as_time < Time.now
  end

  def deadline_as_time
    (deadline + 1).in_time_zone("UTC")
  end

  def to_csv
    CSV.generate do |csv|
      csv << ["Name", "Email", "Why do you want to attend #{self.name} and what especially do you look forward to learning?", "Please share with us why you're applying for a diversity ticket."]
      applications.each do |application|
        csv << [application.name, application.email, application.attendee_info_1, application.attendee_info_2]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12073632918245804, 'fraction_numerical': 0.0024363833243096914, 'mean_word_length': 3.868247694334651, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, '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': '1312622', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1188, 'n_words': 335}