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