added views only for index

This commit is contained in:
Adrian Hinz 2022-09-30 23:13:32 +02:00
parent 02c3d5c4ce
commit 542da6aaf0
2 changed files with 10 additions and 4 deletions

View File

@ -20,10 +20,10 @@ class DashboardController < ApplicationController
def visits_data
@monitor << [
VisitHistory.visits.count,
VisitHistory.visits.by_today.size,
VisitHistory.visits.by_7days.size,
VisitHistory.visits.by_30days.size
VisitHistory.visits.si_index.count,
VisitHistory.visits.si_index.by_today.size,
VisitHistory.visits.si_index.by_7days.size,
VisitHistory.visits.si_index.by_30days.size
]
end

View File

@ -33,6 +33,12 @@ class VisitHistory < ApplicationRecord
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 ========================================================