mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 10:21:42 +00:00
optimización: usar las dimensiones como índices y no como texto
`Rollup#where_dimensions` no aprovecha los índices.
This commit is contained in:
parent
fb5cc0aaa7
commit
f72d27c308
1 changed files with 2 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Implementa rollups recursivos
|
||||
module RecursiveRollup
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
@ -18,9 +19,8 @@ module RecursiveRollup
|
|||
# @param :beginning [Time]
|
||||
# @return [Rollup]
|
||||
def recursive_rollup(name:, interval_previous:, interval:, dimensions:, beginning:, operation: :sum, new_name: nil)
|
||||
Rollup.where(name: name, interval: interval_previous)
|
||||
Rollup.where(name: name, interval: interval_previous, dimensions: dimensions.to_json)
|
||||
.where('time >= ?', beginning.try(:"beginning_of_#{interval}"))
|
||||
.where_dimensions(**dimensions)
|
||||
.group(*dimensions_to_jsonb_query(dimensions))
|
||||
.rollup(new_name || name, interval: interval, update: true) do |rollup|
|
||||
rollup.try(operation, :value)
|
||||
|
|
Loading…
Reference in a new issue