Skip to content

Commit

Permalink
Merge pull request #16928 from lpichler/remove_chargeback_rate_from_m…
Browse files Browse the repository at this point in the history
…etering_reports

Remove chargeback rate from metering reports
  • Loading branch information
gtanzillo authored Feb 1, 2018
2 parents 8594c3f + b524ccb commit f9887ae
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/models/metering.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
module Metering
extend ActiveSupport::Concern

included do
DISALLOWED_SUFFIXES = %w(_cost chargeback_rates).freeze

def self.attribute_names
super.reject { |x| x.ends_with?(*DISALLOWED_SUFFIXES) }
end
end

def calculate_costs(consumption, _)
self.fixed_compute_metric = consumption.chargeback_fields_present if consumption.chargeback_fields_present
self.metering_used_metric = consumption.metering_used_fields_present if consumption.metering_used_fields_present
Expand Down
1 change: 0 additions & 1 deletion lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@ def self.reporting_available_fields(model, interval = nil)
model.constantize.try(:refresh_dynamic_metric_columns)
md = model_details(model, :include_model => false, :include_tags => true).select do |c|
allowed_suffixes = ReportController::Reports::Editor::CHARGEBACK_ALLOWED_FIELD_SUFFIXES
allowed_suffixes -= ['_cost'] if model.starts_with?('Metering')
c.last.ends_with?(*allowed_suffixes)
end
td = if TAG_CLASSES.include?(cb_model)
Expand Down
34 changes: 34 additions & 0 deletions spec/models/metering_vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,38 @@
end
end
end

let(:allowed_attributes) do
%w(start_date
end_date
interval_name
display_range
entity
tag_name
label_name
fixed_compute_metric
id
vm_id
vm_name
vm_uid
vm_guid
owner_name
provider_name
provider_uid
cpu_allocated_metric
cpu_used_metric
disk_io_used_metric
memory_allocated_metric
memory_used_metric
net_io_used_metric
storage_allocated_metric
storage_used_metric
metering_used_metric
existence_hours_metric
)
end

it 'lists proper attributes' do
expect(described_class.attribute_names).to match_array(allowed_attributes)
end
end

0 comments on commit f9887ae

Please sign in to comment.