Skip to content

Commit

Permalink
Merge pull request #5 from adamruzicka/fix-grouping
Browse files Browse the repository at this point in the history
Fix grouping report
  • Loading branch information
ShimShtein authored Dec 9, 2024
2 parents b6b8280 + d1267f7 commit bb123e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions definitions/reports/grouping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ def run
SQL
hostgroup_nest_level = sql_count(sql)
table_preference_count = sql_count('table_preferences')
config_group_count = sql_count('config_groups')

if table_exists('config_groups')
config_group_count = sql_count('config_groups')
end
self.data = { 'host_collections_count': collection_count,
'host_collections_count_with_limit': collection_count_with_limit,
'hostgroup_count': hostgroup,
'hostgroup_nesting': hostgroup_nest_level > 1,
'hostgroup_max_nesting_level': hostgroup.zero? ? 0 : hostgroup_nest_level,
'use_selectable_columns': table_preference_count > 0,
'config_group_count': config_group_count }
'config_group_count': config_group_count || 0 }
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/foreman_maintain/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def sql_setting(name)
(result || {})['value']
end

def table_exists(table)
sql_count("information_schema.tables WHERE table_name = '#{table}'").positive?
end

def run
raise NotImplementedError
end
Expand Down

0 comments on commit bb123e9

Please sign in to comment.