diff --git a/lib/puppet-ghostbuster/puppetdb.rb b/lib/puppet-ghostbuster/puppetdb.rb index f6fa532..e105fdc 100644 --- a/lib/puppet-ghostbuster/puppetdb.rb +++ b/lib/puppet-ghostbuster/puppetdb.rb @@ -40,9 +40,9 @@ def client def self.classes @@classes ||= client.request('', - 'resources[title] { type = "Class" and nodes { deactivated is null } }').data.map do |r| + 'resources[title] { type = "Class" and nodes { deactivated is null } group by title }').data.map do |r| r['title'] - end.uniq + end end def classes @@ -50,9 +50,9 @@ def classes end def self.resources - @@resources ||= client.request('', 'resources[type] { nodes { deactivated is null } }').data.map do |r| + @@resources ||= client.request('', 'resources[type] { nodes { deactivated is null } group by type }').data.map do |r| r['type'] - end.uniq + end end def resources diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fceefe0..6f4af69 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,6 +21,7 @@ def pql_to_jgrep(query) endpoint_cols = query.split('{').first endpoint = endpoint_cols.split(/[\s\[]/).first query.sub!(/^#{Regexp.quote(endpoint_cols)}\{\s*/, '') + query.sub!(/(group\s+by\s+(type|title))/, '') query.sub!(/\s*}\s*/, '') query.sub!(/(and\s+)?nodes\s*\{\s*deactivated\s+is\s+null\s*\}/, '')