From a29b9404fcc4de8a12dfdd28f8669d6b971cd24f Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 7 Dec 2017 16:22:20 -0500 Subject: [PATCH] Moving miq reportable over to ui-classic new home is ReportFormatter::Converter The high level goal is to remove ruport out of the main repo --- app/models/miq_filter.rb | 4 ---- app/models/miq_reportable.rb | 33 --------------------------------- 2 files changed, 37 deletions(-) delete mode 100644 app/models/miq_reportable.rb diff --git a/app/models/miq_filter.rb b/app/models/miq_filter.rb index 02d2e64cb7d..d89e210f680 100644 --- a/app/models/miq_filter.rb +++ b/app/models/miq_filter.rb @@ -1,8 +1,4 @@ module MiqFilter - def self.records2table(records, only_columns) - MiqReportable.records2table(records, only_columns) - end - def self.belongsto2object(tag) belongsto2object_list(tag).last end diff --git a/app/models/miq_reportable.rb b/app/models/miq_reportable.rb deleted file mode 100644 index d5e715c87f9..00000000000 --- a/app/models/miq_reportable.rb +++ /dev/null @@ -1,33 +0,0 @@ -module MiqReportable - # generate a ruport table from an array of db objects - def self.records2table(records, only_columns) - return Ruport::Data::Table.new if records.blank? - - data_records = records.map do |r| - only_columns.each_with_object({}) do |column, attrs| - attrs[column] = r.send(column) if r.respond_to?(column) - end - end - - column_names = data_records.flat_map(&:keys).uniq - - Ruport::Data::Table.new(:data => data_records, - :column_names => column_names) - end - - # generate a ruport table from an array of hashes where the keys are the column names - def self.hashes2table(hashes, options) - return Ruport::Data::Table.new if hashes.blank? - - data = hashes.inject([]) do |arr, h| - nh = {} - options[:only].each { |col| nh[col] = h[col] } - arr << nh - end - - data = data[0..options[:limit] - 1] if options[:limit] # apply limit - Ruport::Data::Table.new(:data => data, - :column_names => options[:only], - :filters => options[:filters]) - end -end