usar guards

This commit is contained in:
f 2021-10-09 15:52:18 -03:00
parent f36ea9629d
commit 5ca8e3c923

View file

@ -29,7 +29,8 @@ class StatsController < ApplicationController
# Genera un gráfico de visitas por dominio asociado a este sitio # Genera un gráfico de visitas por dominio asociado a este sitio
def host def host
if stale? [last_stat, hostnames, interval] return unless stale? [last_stat, hostnames, interval]
stats = Rollup.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series| stats = Rollup.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series|
series.each do |serie| series.each do |serie|
serie[:name] = serie.dig(:dimensions, 'host') serie[:name] = serie.dig(:dimensions, 'host')
@ -41,10 +42,10 @@ class StatsController < ApplicationController
render json: stats render json: stats
end end
end
def resources def resources
if stale? [last_stat, interval, resource] return unless stale? [last_stat, interval, resource]
options = { options = {
interval: interval, interval: interval,
dimensions: { dimensions: {
@ -54,7 +55,6 @@ class StatsController < ApplicationController
render json: Rollup.series(resource, **options) render json: Rollup.series(resource, **options)
end end
end
private private