Sha256: f31757dc6aab932b094e6c5e2e77b6d148a952f1ddf0e332dd220d6d2661ec4e

Contents?: true

Size: 935 Bytes

Versions: 4

Compression:

Stored size: 935 Bytes

Contents

module ThreeScaleToolbox
  module Tasks
    class CopyMetricsTask
      include CopyTask

      def call
        source_metrics = source.metrics
        target_metrics = target.metrics

        puts "original service has #{source_metrics.size} metrics"
        puts "target service has #{target_metrics.size} metrics"

        missing = missing_metrics(source_metrics, target_metrics)

        missing.each do |metric|
          metric.delete('links')
          target.create_metric(metric)
        end

        puts "created #{missing.size} metrics on the target service"
      end

      private

      def missing_metrics(source_metrics, target_metrics)
        ThreeScaleToolbox::Helper.array_difference(source_metrics,
                                                   target_metrics) do |source, target|
          ThreeScaleToolbox::Helper.compare_hashes(source, target, ['system_name'])
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
3scale_toolbox-0.9.0 lib/3scale_toolbox/tasks/copy_metrics_task.rb
3scale_toolbox-0.8.0 lib/3scale_toolbox/tasks/copy_metrics_task.rb
3scale_toolbox-0.7.0 lib/3scale_toolbox/tasks/copy_metrics_task.rb
3scale_toolbox-0.6.0 lib/3scale_toolbox/tasks/copy_metrics_task.rb