usar guards
This commit is contained in:
parent
f36ea9629d
commit
5ca8e3c923
1 changed files with 18 additions and 18 deletions
|
@ -29,31 +29,31 @@ class StatsController < ApplicationController
|
|||
|
||||
# Genera un gráfico de visitas por dominio asociado a este sitio
|
||||
def host
|
||||
if stale? [last_stat, hostnames, interval]
|
||||
stats = Rollup.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series|
|
||||
series.each do |serie|
|
||||
serie[:name] = serie.dig(:dimensions, 'host')
|
||||
serie[:data].transform_values! do |value|
|
||||
value * nodes
|
||||
end
|
||||
return unless stale? [last_stat, hostnames, interval]
|
||||
|
||||
stats = Rollup.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series|
|
||||
series.each do |serie|
|
||||
serie[:name] = serie.dig(:dimensions, 'host')
|
||||
serie[:data].transform_values! do |value|
|
||||
value * nodes
|
||||
end
|
||||
end
|
||||
|
||||
render json: stats
|
||||
end
|
||||
|
||||
render json: stats
|
||||
end
|
||||
|
||||
def resources
|
||||
if stale? [last_stat, interval, resource]
|
||||
options = {
|
||||
interval: interval,
|
||||
dimensions: {
|
||||
deploy_id: @site.deploys.where(type: 'DeployLocal').pluck(:id).first
|
||||
}
|
||||
}
|
||||
return unless stale? [last_stat, interval, resource]
|
||||
|
||||
render json: Rollup.series(resource, **options)
|
||||
end
|
||||
options = {
|
||||
interval: interval,
|
||||
dimensions: {
|
||||
deploy_id: @site.deploys.where(type: 'DeployLocal').pluck(:id).first
|
||||
}
|
||||
}
|
||||
|
||||
render json: Rollup.series(resource, **options)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue