forked from saurabh/orbit4-5
update dashboard for better performance
This commit is contained in:
parent
5f50d59333
commit
c2c9bd4682
|
@ -4,33 +4,12 @@ class Admin::DashboardsController < ApplicationController
|
||||||
layout "basic_back_end"
|
layout "basic_back_end"
|
||||||
|
|
||||||
def index
|
def index
|
||||||
apps = ['bulletin', 'page', 'web_link']
|
apps = ['bulletin', 'page_context', 'web_link']
|
||||||
@module_app_contents, @module_app_contents_total = get_module_app_count(apps)
|
@module_app_contents, @module_app_contents_total = get_module_app_count(apps)
|
||||||
@recent_updated = get_recently_updated(apps)
|
@recent_updated = get_recently_updated(apps)
|
||||||
@most_visited = get_most_visited(apps)
|
@most_visited = get_most_visited(apps)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_all_content
|
|
||||||
@module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'page_context', 'web_link')
|
|
||||||
respond_to do |format|
|
|
||||||
format.js { render 'reload', locals: {div_id: 'all_content'} }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def reload_most_visited
|
|
||||||
@most_visited = get_most_visited('bulletin', 'page_context','page')
|
|
||||||
respond_to do |format|
|
|
||||||
format.js { render 'reload', locals: {div_id: 'most_visited'} }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def reload_recent_update
|
|
||||||
@recent_updated = get_recently_updated('bulletin', 'page_context', 'web_link')
|
|
||||||
respond_to do |format|
|
|
||||||
format.js { render 'reload', locals: {div_id: 'recent_update'} }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_cpu_usage
|
def get_cpu_usage
|
||||||
@usw = Usagewatch
|
@usw = Usagewatch
|
||||||
render :js => @usw.uw_cpuused.to_s
|
render :js => @usw.uw_cpuused.to_s
|
||||||
|
|
|
@ -117,16 +117,24 @@ module OrbitBackendHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_month_traffic
|
def get_month_traffic
|
||||||
result = []
|
site = Site.first
|
||||||
(0..30).each do |i|
|
if site.month_traffic_cache.blank? or (site.month_traffic_cache['updated_at'] < (Time.now-1.day) rescue true)
|
||||||
visits = Impression.where( created_at: {
|
site.month_traffic_cache = {}
|
||||||
'$gte' => Time.now.beginning_of_day-i.days,
|
|
||||||
'$lte' => Time.now.end_of_day-i.days}
|
site.month_traffic_cache['result'] = []
|
||||||
).distinct(:request_hash).count
|
(1..30).each do |i|
|
||||||
result.push([ Time.now.beginning_of_day-i.days, visits])
|
visits = Impression.where( created_at: {
|
||||||
|
'$gte' => Time.now.beginning_of_day-i.days,
|
||||||
|
'$lte' => Time.now.end_of_day-i.days}
|
||||||
|
).distinct(:request_hash).count
|
||||||
|
site.month_traffic_cache['result'].push([ Time.now.beginning_of_day-i.days, visits])
|
||||||
|
end
|
||||||
|
|
||||||
|
site.month_traffic_cache['updated_at'] = Time.now
|
||||||
|
site.save
|
||||||
end
|
end
|
||||||
|
|
||||||
[:name=> t(:visitors_count),:data=>result]
|
[:name=> t(:visitors_count),:data=>site.month_traffic_cache['result']]
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_edit_or_delete?(obj)
|
def can_edit_or_delete?(obj)
|
||||||
|
|
|
@ -34,6 +34,8 @@ class Site
|
||||||
field :site_token
|
field :site_token
|
||||||
field :store_confirmation, type: Boolean, default: false
|
field :store_confirmation, type: Boolean, default: false
|
||||||
|
|
||||||
|
field :month_traffic_cache
|
||||||
|
|
||||||
mount_uploader :default_image, ImageUploader
|
mount_uploader :default_image, ImageUploader
|
||||||
mount_uploader :site_logo, ImageUploader
|
mount_uploader :site_logo, ImageUploader
|
||||||
mount_uploader :favicon, ImageUploader
|
mount_uploader :favicon, ImageUploader
|
||||||
|
|
|
@ -18,7 +18,7 @@ var Gages = { 'CPU':{
|
||||||
'container': 'cpu_usage',
|
'container': 'cpu_usage',
|
||||||
'title': 'CPU Usage',
|
'title': 'CPU Usage',
|
||||||
'fn': 'get_cpu_usage',
|
'fn': 'get_cpu_usage',
|
||||||
'update_interval': 2000,
|
'update_interval': 3000,
|
||||||
'initialized': false
|
'initialized': false
|
||||||
},
|
},
|
||||||
'Mem':{
|
'Mem':{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
legend: 'none',
|
legend: 'none',
|
||||||
chartArea:{ width: '95%', left: 50, right: 0},
|
chartArea:{ width: '95%', left: 50, right: 0},
|
||||||
hAxis:{format:'MMM-d',gridlines:{color: '#CCC', count: 31}},
|
hAxis:{format:'MMM-d',gridlines:{color: '#CCC', count: 31}},
|
||||||
vAxis:{minValue:-100,viewWindowMode: 'maximized'}
|
vAxis:{minValue:-20,viewWindowMode: 'maximized'}
|
||||||
} %>
|
} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue