<commit_before># -*- encoding: utf-8 -*-
class Reserve < ActiveRecord::Base
  attr_accessible :manifestation_id, :user_number, :expired_at
  attr_accessible :expired_at, :as => :user_update
  attr_accessible :manifestation_id, :item_identifier, :user_number,
    :expired_at, :request_status_type, :canceled_at, :checked_out_at,
    :expiration_notice_to_patron, :expiration_notice_to_library, :item_id,
    :retained_at, :postponed_at, :force_retaining,
    :as => :admin
  scope :hold, where('item_id IS NOT NULL')
  scope :not_hold, where(:item_id => nil)
  scope :waiting, where('canceled_at IS NULL AND expired_at > ? AND state != ?', Time.zone.now, 'completed').order('reserves.id DESC')
  scope :retained, where('retained_at IS NOT NULL AND state = ?', 'retained')
  scope :completed, where('checked_out_at IS NOT NULL AND state = ?', 'completed')
  scope :canceled, where('canceled_at IS NOT NULL AND state = ?', 'canceled')
  scope :postponed, where('postponed_at IS NOT NULL AND state = ?', 'postponed')
  scope :will_expire_retained, lambda {|datetime| where('checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ? AND state = ?', datetime, 'retained').order('expired_at')}
  scope :will_expire_pending, lambda {|datetime| where('checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ? AND state = ?', datetime, 'pending').order('expired_at')}
  scope :created, lambda {|start_date, end_date| where('created_at >= ? AND created_at < ?', start_date, end_date)}
  scope :not_sent_expiration_notice_to_patron, {where(:state => 'expired', :expiration_notice_to_patron => false)}
  scope :not_sent_expiration_notice_to_library, {where(:state => 'expired', :expiration_notice_to_library => false)}
  scope :sent_expiration_notice_to_patron, {where(:state => 'expired', :expiration_notice_to_patron => true)}
  scope :sent_expiration_notice_to_library, {where(:state => 'expired', :expiration_notice_to_library => true)}
  scope :not_sent_cancel_notice_to_agent, {where(:state => 'canceled', :expiration_notice_to_patron => false)}
  scope :not_sent_cancel_notice_to_library, {where(:state => 'canceled', :expiration_notice_to_library => false)}

  belongs_to :user #, :validate => true
  belongs_to :manifestation #, :validate => true
  belongs_to :librarian, :class_name => 'User' #, :validate => true
  belongs_to :item #, :validate => true
  belongs_to :request_status_type

  validates_associated :user, :librarian, :request_status_type<commit_msg>fixed scope<commit_after># -*- encoding: utf-8 -*-
class Reserve < ActiveRecord::Base
  attr_accessible :manifestation_id, :user_number, :expired_at
  attr_accessible :expired_at, :as => :user_update
  attr_accessible :manifestation_id, :item_identifier, :user_number,
    :expired_at, :request_status_type, :canceled_at, :checked_out_at,
    :expiration_notice_to_patron, :expiration_notice_to_library, :item_id,
    :retained_at, :postponed_at, :force_retaining,
    :as => :admin
  scope :hold, where('item_id IS NOT NULL')
  scope :not_hold, where(:item_id => nil)
  scope :waiting, where('canceled_at IS NULL AND expired_at > ? AND state != ?', Time.zone.now, 'completed').order('reserves.id DESC')
  scope :retained, where('retained_at IS NOT NULL AND state = ?', 'retained')
  scope :completed, where('checked_out_at IS NOT NULL AND state = ?', 'completed')
  scope :canceled, where('canceled_at IS NOT NULL AND state = ?', 'canceled')
  scope :postponed, where('postponed_at IS NOT NULL AND state = ?', 'postponed')
  scope :will_expire_retained, lambda {|datetime| where('checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ? AND state = ?', datetime, 'retained').order('expired_at')}
  scope :will_expire_pending, lambda {|datetime| where('checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ? AND state = ?', datetime, 'pending').order('expired_at')}
  scope :created, lambda {|start_date, end_date| where('created_at >= ? AND created_at < ?', start_date, end_date)}
  scope :not_sent_expiration_notice_to_patron, -> {where(:state => 'expired', :expiration_notice_to_patron => false)}
  scope :not_sent_expiration_notice_to_library, -> {where(:state => 'expired', :expiration_notice_to_library => false)}
  scope :sent_expiration_notice_to_patron, -> {where(:state => 'expired', :expiration_notice_to_patron => true)}
  scope :sent_expiration_notice_to_library, -> {where(:state => 'expired', :expiration_notice_to_library => true)}
  scope :not_sent_cancel_notice_to_agent, -> {where(:state => 'canceled', :expiration_notice_to_patron => false)}
  scope :not_sent_cancel_notice_to_library, -> {where(:state => 'canceled', :expiration_notice_to_library => false)}

  belongs_to :user #, :validate => true
  belongs_to :manifestation #, :validate => true
  belongs_to :librarian, :class_name => 'User' #, :validate => true
  belongs_to :item #, :validate => true
  belongs_to :request_status_type

  validates_associated :user, :librarian, :request_status_type
{'fraction_non_alphanumeric': 0.1342443729903537, 'fraction_numerical': 0.00040192926045016077, 'mean_word_length': 6.586890243902439, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, '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': '6304483', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1667, 'n_words': 384}