Completed
Push — master ( e56411...e397a9 )
by Michael
03:06
created

NoSECLI.output_diff()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.6296

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 10
ccs 1
cts 7
cp 0.1429
crap 1.6296
rs 9.4285
c 0
b 0
f 0
1
# frozen_string_literal: true
2
3 1
module NoSE
4 1
  module CLI
5
    # Add a command to generate a graphic of the schema from a workload
6 1
    class NoSECLI < Thor
7 1
      desc 'diff-plans PLAN1 PLAN2',
8
           'output the differing plans between PLAN1 and PLAN2'
9
10 1
      long_desc <<-LONGDESC
11
        `nose diff-plans` loads two sets of statement plans generated
12
        separately by `nose search` and outputs the plans which are different.
13
      LONGDESC
14
15 1
      def diff_plans(plan1, plan2)
16
        result1 = load_results plan1
17
        result2 = load_results plan2
18
19
        output_diff plan1, result1, result2
20
        output_diff plan2, result2, result1
21
      end
22
23 1
      private
24
25
      # Output differing plans between two sets of results
26
      # @return [void]
27 1
      def output_diff(plan_name, result1, result2)
28
        puts Formatador.parse("[blue]#{plan_name}\n" + '━' * 50 + '[/]')
29
        plans1 = result1.plans.reject { |p| result2.plans.include?(p) }
30
        output_plans_txt plans1, $stdout, 1, result1.workload.statement_weights
31
        plans1 = result1.update_plans.reject do |plan|
32
          result2.update_plans.include? plan
33
        end
34
        output_update_plans_txt plans1, $stdout,
35
                                result1.workload.statement_weights
36
      end
37
    end
38
  end
39
end
40