From 158c2244490fc79467d915e4841b6d54a34e4a49 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 30 Apr 2022 20:40:54 -0300 Subject: [PATCH] generar los rollups para los siguientes intervalos --- app/jobs/uri_collection_job.rb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/jobs/uri_collection_job.rb b/app/jobs/uri_collection_job.rb index ca755ca1..0ea468da 100644 --- a/app/jobs/uri_collection_job.rb +++ b/app/jobs/uri_collection_job.rb @@ -11,8 +11,6 @@ # Los hostnames de un sitio van a poder obtenerse a partir de # Site#hostnames con la garantía de que son únicos. class UriCollectionJob < PeriodicJob - include RecursiveRollup - # Ignoramos imágenes porque suelen ser demasiadas y no aportan a las # estadísticas. IMAGES = %w[.png .jpg .jpeg .gif .webp .jfif].freeze @@ -76,13 +74,29 @@ class UriCollectionJob < PeriodicJob # @param :dimensions [Hash] # @param :filter [Hash] # @return [nil] - def rollup(name:, dimensions:, filter: nil) + def rollup(name:, dimensions:, interval: starting_interval, filter: nil) AccessLog.where(**(filter || dimensions)) .where('created_at >= ?', beginning_of_interval) .completed_requests .non_robots .group(*dimensions.keys) - .rollup(name, interval: starting_interval, update: true) + .rollup(name, interval: interval, update: true) + end + + # Generar rollups con el resto de la información + # + # @param :name [String] + # @param :dimensions [Hash] + # @param :filter [Hash] + # @return [nil] + def reduce_rollup(name:, dimensions:, filter: nil) + Stat::INTERVALS.reduce do |_previous, current| + rollup(name: name, dimensions: dimensions, filter: filter, interval: current) + + current + end + + nil end def stat_name