class InformationStandardStatistic < ActiveRecord::Base

  attr_accessible :information_standard_id,
                  :institution_id,
                  :sessions,
                  :tracked_date,
                  :views

  belongs_to :information_standard

  def self.by_tracked_date(date)
    where('DATE(tracked_date) = ?', date)
  end

  def self.by_information_standard_ids(information_standard_ids)
    unless information_standard_ids.empty?
      where(information_standard_id: information_standard_ids)
    else
      where('1 = 0')
    end
  end

  def self.by_institution_ids(institution_ids)
    unless institution_ids.empty?
      where(institution_id: institution_ids)
    else
      where('1 = 0')
    end
  end
end
