Skip to content

Commit 13b942b

Browse files
committed
invent_report_includes now properly returns tags and sortby
The goal is to ensure that the invented includes matches those generated by reports. - It was missing the "include" section - It was not adding acknowledging tags - It was not adding sort columns Still does not support virtual_custm attributes
1 parent d7ac8d9 commit 13b942b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

app/models/miq_report/generator.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,14 @@ def invent_includes
103103
# would like this format to go away
104104
# will go away when we drop build_reportable_data
105105
def invent_report_includes
106-
return {} unless col_order
107-
108-
col_order.each_with_object({}) do |col, ret|
109-
next unless col.include?(".")
106+
(Array(col_order) + Array(sortby)).each_with_object({}) do |col, ret|
107+
next if !col.include?(".") || col.include?("virtual_custom")
110108

111109
*rels, column = col.split(".")
112-
if col !~ /managed\./ && col !~ /virtual_custom/
113-
(rels.inject(ret) { |h, rel| h[rel] ||= {} }["columns"] ||= []) << column
114-
end
115-
end
110+
dest = rels.inject(ret) { |h, rel| (h["include"] ||= {})[rel] ||= {} }["columns"] ||= []
111+
# sortby tends to be a duplicate. So suppress duplicates for all
112+
dest << column unless dest.include?(column)
113+
end["include"]
116114
end
117115

118116
def include_as_hash(includes = include, klass = db_class, klass_cols = cols)

0 commit comments

Comments
 (0)