Skip to content

Commit

Permalink
Merge pull request #665 from himdel/dead-base
Browse files Browse the repository at this point in the history
Compare - remove dead compare_set_base, {compare,drift}_matches, @base
  • Loading branch information
mzazrivec authored Mar 15, 2017
2 parents 4390b5d + dd7bb94 commit f22f681
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 77 deletions.
69 changes: 0 additions & 69 deletions app/controllers/application_controller/compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ def create_compare_or_drift_report(mode, csv = false)
# Initialize the VM compare array
def compare_init(mode)
@compare = nil # Clear the compare array to have it rebuilt
@base = nil # Clear the base comparison VM
if mode == "compare"
session[:miq_compressed] = (settings(:views, :compare) == "compressed")
session[:miq_exists_mode] = (settings(:views, :compare_mode) == "exists")
Expand All @@ -749,74 +748,6 @@ def compare_init(mode)
@exists_mode = session[:miq_exists_mode]
end

# Set a given VM id as the base vm for compare
def compare_set_base(baseid)
@compare.results[1..-1].each do |c|
if c[:object].id == baseid
@base = c
break
end
end

compare_matches # Go calc match %s against the new base
end

# Calculate the value matches in each compare section
def compare_matches
@compare.results.each_with_index do |r, idx| # Go thru each VM result
if idx != 0
all_total = 0; all_matches = 0
session[:miq_sections].each do |s| # Go thru each section
section = s[:name]
if s[:added] == true # Only if section has data
count = 0
r[:results][s[:name]].each_with_index do |val, val_idx| # Go thru each value
count += 1 if val == @base[:results][s[:name]][val_idx] # count matches between the value and the base value
end
if r[:results][s[:name]].length > 0
r[:results][s[:name] + "_match"] = (count * 100) / r[:results][s[:name]].length # Set the percent of matches for the VM to the base
if s[:checked] == true # Only if section is currently checked
all_matches += count # Add count to the total matches
all_total += r[:results][s[:name]].length # Add total to the grand total
end
else
r[:results][s[:name] + "_match"] = 0
end
end
end
r[:results]["all_match"] = all_total == 0 ? 0 : all_matches * 100 / all_total # Calculate the total matches percent
end
end
end

# Calculate the value matches in each drift section
def drift_matches
@compare.results.each_with_index do |r, idx| # Go thru each VM result
if idx > 1 # Skip master list and first timestamp
all_match = true
prev = ""
session[:miq_sections].each do |s| # Go thru each section
section = s[:name]
match = true
if s[:added] == true # Only if section has data
r[:results][s[:name]].each_with_index do |val, val_idx| # Go thru each value
if val != @compare.results[idx - 1][:results][s[:name]][val_idx] # Compare to previous timestamp entry
match = false # Doesn't match, set it and
break # move on to the next section
end
end
r[:results][s[:name] + "_match"] = match # Set section match = true or false
if s[:checked] == true # Only if section is currently checked
all_match = match && all_match # Set all_match
end
end
end
r[:results]["all_match"] = all_match # Set all match value in the object
end
end
end
####### End of compare & drift related methods

# Compare selected VMs
def comparemiq
assert_privileges(params[:pressed])
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/host_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ def get_session_data
@display = session[:host_display]
@filters = session[:host_filters]
@catinfo = session[:host_catinfo]
@base = session[:vm_compare_base]
end

def set_session_data
Expand All @@ -663,7 +662,6 @@ def set_session_data
session[:host_catinfo] = @catinfo
session[:miq_compressed] = @compressed unless @compressed.nil?
session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil?
session[:vm_compare_base] = @base
end

menu_section :inf
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/miq_template_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def get_session_data
@layout = session[:miq_template_type] ? session[:miq_template_type] : "miq_template"
@lastaction = session[:miq_template_lastaction]
@showtype = session[:miq_template_showtype]
@base = session[:miq_template_compare_base]
@filters = session[:miq_template_filters]
@catinfo = session[:miq_template_catinfo]
@display = session[:miq_template_display]
Expand All @@ -35,7 +34,6 @@ def set_session_data
session[:miq_template_showtype] = @showtype
session[:miq_compressed] = @compressed unless @compressed.nil?
session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil?
session[:miq_template_compare_base] = @base
session[:miq_template_filters] = @filters
session[:miq_template_catinfo] = @catinfo
session[:miq_template_display] = @display unless @display.nil?
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/mixins/vm_show_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def get_session_data
@layout = controller_name
@lastaction = session[:vm_lastaction]
@showtype = session[:vm_showtype]
@base = session[:vm_compare_base]
@filters = get_filters
@catinfo = session[:vm_catinfo]
@display = session[:vm_display]
Expand All @@ -148,7 +147,6 @@ def set_session_data
session[:vm_showtype] = @showtype
session[:miq_compressed] = @compressed unless @compressed.nil?
session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil?
session[:vm_compare_base] = @base
session[:vm_filters] = @filters
session[:vm_catinfo] = @catinfo
session[:vm_display] = @display unless @display.nil?
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/vm_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def get_session_data
@layout = "vm"
@lastaction = session[:vm_lastaction]
@showtype = session[:vm_showtype]
@base = session[:vm_compare_base]
@filters = session[:vm_filters]
@catinfo = session[:vm_catinfo]
@display = session[:vm_display]
Expand All @@ -37,7 +36,6 @@ def set_session_data
session[:vm_showtype] = @showtype
session[:miq_compressed] = @compressed unless @compressed.nil?
session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil?
session[:vm_compare_base] = @base
session[:vm_filters] = @filters
session[:vm_catinfo] = @catinfo
session[:vm_display] = @display unless @display.nil?
Expand Down

0 comments on commit f22f681

Please sign in to comment.