5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 05:24:17 +00:00

deprecar square_rollup

es muy lento buscar dentro de cada dimensión
This commit is contained in:
f 2022-04-30 17:51:05 -03:00
parent d766ee4eff
commit fb34823ce3
2 changed files with 2 additions and 31 deletions

View file

@ -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.
#

View file

@ -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