Orbit/app/jobs/dashboard_counter.rb

20 lines
739 B
Ruby

class DashboardCounter < Resque::Plugins::RestrictionJob
include OrbitApp::Module::VisitorCounter
@queue = :high
def self.perform(*args)
site = Site.first
obj = new(*args)
site.dashboard_counter[:visitors_this_week] = obj.display_visitors_this_week
site.dashboard_counter[:visitors_this_month] = obj.display_visitors_this_month
site.dashboard_counter[:visitors_this_year] = obj.display_visitors_this_year
site.save
OrbitLogger.info "DashboardCounter done #{site.dashboard_counter.to_s}"
#Notice this is mainly used at user dashbroad. however the code there is currentlly using realtime evaluation.
#and the site model will need a field call dashboard_counter to complete this job.
end
end