Sha256: 45404a7e8ed25281aec8e2d05ac2c3c5a9b02faec4b2c4b776343634b501a5fa

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

module ThreeScaleToolbox
  module Commands
    module BackendCommand
      module CopyCommand
        class CopyMetricsTask
          include Task

          # entrypoint
          def run
            missing_metrics.each(&method(:create_metric))
            puts "created #{missing_metrics.size} missing metrics"
            invalidate_target_metrics if missing_metrics.size.positive?
          end

          private

          def create_metric(metric)
            Entities::BackendMetric.create(backend: target_backend, attrs: metric.attrs)
          end

          def missing_metrics
            @missing_metrics ||= ThreeScaleToolbox::Helper.array_difference(source_metrics, target_metrics) do |source, target|
              source.system_name == target.system_name
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb