todas las peticiones necesitan une usuarie

This commit is contained in:
f 2021-10-08 18:33:31 -03:00
parent a2e4e0ab89
commit cfb2d7a61d

View file

@ -4,6 +4,7 @@
class StatsController < ApplicationController
include Pundit
before_action :authenticate_usuarie!
before_action :authorize_stats
INTERVALS = %i[hour day week month].freeze
@ -14,9 +15,6 @@ class StatsController < ApplicationController
end
def index
@site = find_site
authorize SiteStat.new(@site)
@chart_params = { interval: interval }
hostnames
last_stat
@ -24,8 +22,6 @@ class StatsController < ApplicationController
# Genera un gráfico de visitas por dominio asociado a este sitio
def host
@site = find_site
authorize SiteStat.new(@site)
@stats = Rollup.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series|
series.each do |serie|
@ -45,6 +41,11 @@ class StatsController < ApplicationController
@last_stat ||= Stat.last
end
def authorize_stats
@site = find_site
authorize SiteStat.new(@site)
end
# TODO: Eliminar cuando mergeemos referer-origin
def hostnames
@hostnames ||= [@site.hostname, @site.alternative_hostnames].flatten