Sha256: 4dc690a654f417c3fdf1d192181b8e9467b1b04afc9cb33583e96c653f50b532

Contents?: true

Size: 851 Bytes

Versions: 10

Compression:

Stored size: 851 Bytes

Contents

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

          # entrypoint
          def run
            missing_metrics.each(&method(:create_metric))
            logger.info "created #{missing_metrics.size} missing metrics"
            report['missing_metrics_created'] = missing_metrics.size
          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_backend.metrics, target_backend.metrics) do |s_m, t_m|
              s_m.system_name == t_m.system_name
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb