<commit_before>class SingleEvent < ActiveRecord::Base

  after_destroy :update_event

  belongs_to :category
  belongs_to :venue
  belongs_to :event
  belongs_to :picture

  delegate :title, :description, to: :event, prefix: true

  has_many :comments, as: :commentable, dependent: :destroy
  has_and_belongs_to_many :users, uniq: true

  validates_presence_of :event_id

  scope :in_future,
    where("occurrence >= ?", Time.now)
  scope :today_or_in_future,
    where("occurrence >= ?", Time.now.beginning_of_day)
  scope :most_current_for_event,
    order("occurrence DESC")
  scope :recent,
    lambda { |limit = 3| today_or_in_future.limit(limit) }
  scope :rule_based_in_future,
    in_future.where(based_on_rule: true)
  scope :in_next,
    lambda { |delta| where(occurrence: (Time.now.to_date)..((Time.now + delta).to_date)) }
  scope :in_next_from,
    lambda { |delta, start_date| where(occurrence: (start_date)..((start_date + delta).to_date)) }
  scope :recent_to_soon,
    lambda { |delta| where(occurrence: (Time.now.to_date - delta)..((Time.now + delta).to_date)) }
  scope :only_tagged_with,
    lambda { |tag| tagged_with(tag) | joins(:event).where('events.id in (?)', Event.tagged_with(tag).map(&:id)) }
  scope :in_categories,
    lambda { |categories| categories.blank? ? scoped : scoped.joins(:event).where('single_events.category_id IN (?) OR (single_events.category_id IS NULL AND events.category_id IN (?))', categories, categories) }

  default_scope includes(:event).order([:occurrence, 'single_events.name ASC', 'events.name ASC'])
<commit_msg>Show the last day in the mini cal. Fixes #196<commit_after>class SingleEvent < ActiveRecord::Base

  after_destroy :update_event

  belongs_to :category
  belongs_to :venue
  belongs_to :event
  belongs_to :picture

  delegate :title, :description, to: :event, prefix: true

  has_many :comments, as: :commentable, dependent: :destroy
  has_and_belongs_to_many :users, uniq: true

  validates_presence_of :event_id

  scope :in_future,
    where("occurrence >= ?", Time.now)
  scope :today_or_in_future,
    where("occurrence >= ?", Time.now.beginning_of_day)
  scope :most_current_for_event,
    order("occurrence DESC")
  scope :recent,
    lambda { |limit = 3| today_or_in_future.limit(limit) }
  scope :rule_based_in_future,
    in_future.where(based_on_rule: true)
  scope :in_next,
    lambda { |delta| where(occurrence: (Time.now.to_date)..((Time.now + delta).to_date)) }
  scope :in_next_from,
    lambda { |delta, start_date| where(occurrence: (start_date)..((start_date + delta).to_date)) }
  scope :recent_to_soon,
    lambda { |delta| where(occurrence: (Time.now.to_date - delta)..((Time.now + delta).to_date + 1.day)) }
  scope :only_tagged_with,
    lambda { |tag| tagged_with(tag) | joins(:event).where('events.id in (?)', Event.tagged_with(tag).map(&:id)) }
  scope :in_categories,
    lambda { |categories| categories.blank? ? scoped : scoped.joins(:event).where('single_events.category_id IN (?) OR (single_events.category_id IS NULL AND events.category_id IN (?))', categories, categories) }

  default_scope includes(:event).order([:occurrence, 'single_events.name ASC', 'events.name ASC'])

{'fraction_non_alphanumeric': 0.13890634820867379, 'fraction_numerical': 0.0018856065367693275, 'mean_word_length': 5.028409090909091, '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': '6480501', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1090, 'n_words': 226}