From fb34823ce31606c23823d66365ef85438e0e12fa Mon Sep 17 00:00:00 2001 From: f Date: Sat, 30 Apr 2022 17:51:05 -0300 Subject: [PATCH] deprecar square_rollup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit es muy lento buscar dentro de cada dimensión --- app/jobs/concerns/recursive_rollup.rb | 20 -------------------- app/jobs/uri_collection_job.rb | 13 ++----------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/app/jobs/concerns/recursive_rollup.rb b/app/jobs/concerns/recursive_rollup.rb index 28c2e66a..4d9e11b0 100644 --- a/app/jobs/concerns/recursive_rollup.rb +++ b/app/jobs/concerns/recursive_rollup.rb @@ -26,26 +26,6 @@ module RecursiveRollup end end - # Genera un nuevo rollup a partir de uno anterior. - # - # @param :name [String] - # @param :new_name [String] - # @param :interval_previous [String, Symbol] - # @param :interval [String, Symbol] - # @param :operation [Symbol] - # @param :dimensions [Hash] - # @param :beginning [Time] - # @return [Rollup] - def square_rollup(name:, new_name:, interval:, dimensions:, beginning:, operation: :sum) - Rollup.where(name: name, interval: interval) - .where_dimensions(**dimensions) - .where('time >= ?', beginning.try(:"beginning_of_#{interval}")) - .group(*dimensions_to_jsonb_query(dimensions)) - .rollup(new_name, interval: interval, update: true) do |rollup| - rollup.try(operation, :value) - end - end - # Reducir las estadísticas calculadas aplicando un rollup sobre el # intervalo más amplio. # diff --git a/app/jobs/uri_collection_job.rb b/app/jobs/uri_collection_job.rb index a0b1181e..fe50929d 100644 --- a/app/jobs/uri_collection_job.rb +++ b/app/jobs/uri_collection_job.rb @@ -68,11 +68,7 @@ class UriCollectionJob < PeriodicJob end # Reducir todas las visitas a cantidad de visitas por host - square_rollup(name: 'host|uri', - new_name: 'host', - interval: starting_interval, - dimensions: host_dimensions, - beginning: beginning) + rollup('host', beginning, :sum, **host_dimensions) # Acumular por mes y año reduce_rollup('host', beginning, :sum, **host_dimensions) @@ -82,12 +78,7 @@ class UriCollectionJob < PeriodicJob column_dimensions = { host: host } column_dimensions[column] = value - square_rollup(name: "host|uri|#{column}", - new_name: "host|#{column}", - interval: starting_interval, - dimensions: column_dimensions, - beginning: beginning) - + rollup("host|#{column}", beginning, :sum, **column_dimensions) reduce_rollup("host|#{column}", beginning, :sum, **column_dimensions) end end