<commit_before>class Event < ActiveRecord::Base
  belongs_to  :organization
  has_many    :attendances
  has_many    :attendees , through: :attendances, source: :user

  def self.popular_events_by_school(school, number)
    popular_events = Event.future_events.sort_by do |event|
      -event.attendees.select { |attendee| attendee.school == school }.size
    end
    popular_events[0...number]
  end

  def self.popular_events(number)
    Event.select('events.*, count(attendances.id) AS attendance_count')
      .joins(:attendances)
      .group("events.id")
      .where('events.start_date_and_time > ?', Time.now)
      .order("attendance_count DESC")
      .limit(number)
  end

  def self.by_time(start_time, end_time)
    if end_time
      Event.where("start_date_and_time BETWEEN ? AND ?", start_time, end_time)
        .includes(:attendances)
        .order("start_date_and_time")
    else
      Event.where(start_date_and_time: start_time)
        .includes(:attendances)
        .order("start_date_and_time")
    end
  end

  def self.future_events
    Event.where("start_date_and_time > ?", Date.today.beginning_of_day)
      .includes(:attendances)
      .order("start_date_and_time")
      .select { |event| (event.start_date_and_time + event.duration).future? }
  end

  def attendees_by_school(school)
    self.attendees.select { |attendee| attendee.school == school }.count
  end

end
<commit_msg>Add not_over? instance method to Event<commit_after>class Event < ActiveRecord::Base
  belongs_to  :organization
  has_many    :attendances
  has_many    :attendees , through: :attendances, source: :user

  def self.popular_events_by_school(school, number)
    popular_events = Event.future_events.sort_by do |event|
      -event.attendees.select { |attendee| attendee.school == school }.size
    end
    popular_events[0...number]
  end

  def self.popular_events(number)
    Event.select('events.*, count(attendances.id) AS attendance_count')
      .joins(:attendances)
      .group("events.id")
      .where('events.start_date_and_time > ?', Time.now)
      .order("attendance_count DESC")
      .limit(number)
  end

  def self.by_time(start_time, end_time)
    if end_time
      Event.where("start_date_and_time BETWEEN ? AND ?", start_time, end_time)
        .includes(:attendances)
        .order("start_date_and_time")
        .select(&:not_over?)
    else
      Event.where(start_date_and_time: start_time)
        .includes(:attendances)
        .order("start_date_and_time")
        .select(&:not_over?)
    end
  end

  def self.future_events
    Event.where("start_date_and_time > ?", Date.today.beginning_of_day)
      .includes(:attendances)
      .order("start_date_and_time")
      .select(&:not_over?)
  end

  def attendees_by_school(school)
    attendees.select { |attendee| attendee.school == school }.count
  end

  def not_over?
    (start_date_and_time + duration).future?
  end

end

{'fraction_non_alphanumeric': 0.11430527036276524, 'fraction_numerical': 0.0006844626967830253, 'mean_word_length': 3.4287878787878787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5281933', 'n_tokens_mistral': 1015, 'n_tokens_neox': 991, 'n_words': 171}