From 9998f19087318910b70ad69e998bc1c0aaf809a2 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 29 Apr 2022 17:57:29 -0300 Subject: [PATCH] =?UTF-8?q?acumular=20visitas=20por=20pa=C3=ADs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/jobs/uri_collection_job.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/jobs/uri_collection_job.rb b/app/jobs/uri_collection_job.rb index 8504f006..eaa3b153 100644 --- a/app/jobs/uri_collection_job.rb +++ b/app/jobs/uri_collection_job.rb @@ -58,12 +58,20 @@ class UriCollectionJob < PeriodicJob # Acumular por mes y año reduce_rollup('host', beginning, **dimensions) - # Obtener orígenes de visitas por host - AccessLog.where(host: host).distinct(:http_referer).pluck(:http_referer).each do |http_referer| - dimensions[:http_referer] = http_referer + columns = %i[http_referer geoip2_data_country_name] + columns.each do |column| + # Obtener orígenes de visitas por host + AccessLog.where(host: host).distinct(column).pluck(column).each do |value| + dimensions.delete_if do |k, _| + columns.include? k + end - rollup('host|referer', beginning, **dimensions) - reduce_rollup('host|referer', beginning, **dimensions) + name = "host|#{column}" + dimensions[column] = value + + rollup(name, beginning, **dimensions) + reduce_rollup(name, beginning, **dimensions) + end end end