diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index a093747..0eae584 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -25,17 +25,18 @@ class StatsController < ApplicationController # Genera un gráfico de visitas por dominio asociado a este sitio def host - - @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 + 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 end end end - render json: @stats + render json: stats end private