todas las peticiones necesitan une usuarie
This commit is contained in:
parent
a2e4e0ab89
commit
cfb2d7a61d
1 changed files with 6 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
||||||
class StatsController < ApplicationController
|
class StatsController < ApplicationController
|
||||||
include Pundit
|
include Pundit
|
||||||
before_action :authenticate_usuarie!
|
before_action :authenticate_usuarie!
|
||||||
|
before_action :authorize_stats
|
||||||
|
|
||||||
INTERVALS = %i[hour day week month].freeze
|
INTERVALS = %i[hour day week month].freeze
|
||||||
|
|
||||||
|
@ -14,9 +15,6 @@ class StatsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@site = find_site
|
|
||||||
authorize SiteStat.new(@site)
|
|
||||||
|
|
||||||
@chart_params = { interval: interval }
|
@chart_params = { interval: interval }
|
||||||
hostnames
|
hostnames
|
||||||
last_stat
|
last_stat
|
||||||
|
@ -24,8 +22,6 @@ 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
|
||||||
@site = find_site
|
|
||||||
authorize SiteStat.new(@site)
|
|
||||||
|
|
||||||
@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|
|
||||||
|
@ -45,6 +41,11 @@ class StatsController < ApplicationController
|
||||||
@last_stat ||= Stat.last
|
@last_stat ||= Stat.last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authorize_stats
|
||||||
|
@site = find_site
|
||||||
|
authorize SiteStat.new(@site)
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: Eliminar cuando mergeemos referer-origin
|
# TODO: Eliminar cuando mergeemos referer-origin
|
||||||
def hostnames
|
def hostnames
|
||||||
@hostnames ||= [@site.hostname, @site.alternative_hostnames].flatten
|
@hostnames ||= [@site.hostname, @site.alternative_hostnames].flatten
|
||||||
|
|
Loading…
Reference in a new issue