Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare - remove dead compare_set_base, {compare,drift}_matches, @base #665

Merged
merged 2 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -21,7 +21,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]
@cats = session[:miq_template_cats]
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_cats] = @cats
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]
@cats = session[:vm_cats]
Expand All @@ -149,7 +148,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_cats] = @cats
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]
@cats = session[:vm_cats]
Expand All @@ -38,7 +37,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_cats] = @cats
Expand Down