grantcallendar/app/models/visit_history.rb

48 lines
1.6 KiB
Ruby

# frozen_string_literal: true
# event
# 0 - vist
# 1 - search
# 2 - pdf generation
# site
# 0 - index
# 1 - contact
# 2 - regulamin
# 3 - umow_konsultacje
# 4 - monitoring
# 5 - dotacja
# History model
class VisitHistory < ApplicationRecord
# == Constants ============================================================
# == Attributes ===========================================================
# == Extensions ===========================================================
# == Relationships ========================================================
# == Validations ==========================================================
# == Scopes ===============================================================
scope :visits, -> { where(event: 0) }
scope :search, -> { where(event: 1) }
scope :pdf_files, -> { where(event: 2) }
scope :by_today, -> { where('created_at > ?', Time.now.midnight) }
scope :by_7days, -> { where('created_at > ?', Time.now.midnight - 7.days) }
scope :by_30days, -> { where('created_at > ?', Time.now.midnight - 30.days) }
scope :dist_ip, -> { select(:ip_address).uniq }
scope :si_index, -> { where(site: 0) }
scope :si_contact, -> { where(site: 1) }
scope :si_statut, -> { where(site: 2) }
scope :si_visit, -> { where(site: 3) }
scope :si_monitor, -> { where(site: 4) }
scope :si_grant, -> { where(site: 5) }
# == Callbacks ============================================================
# == Class Methods ========================================================
# == Instance Methods =====================================================
end