(ns com.puppetlabs.cmdb.query.population
  (:use [com.puppetlabs.jdbc :only [query-to-vec]]))

(defn correlate-exported-resources
  []
  "Fetch a map of {exported-resource [#{exporting-nodes} #{collecting-nodes}]},
  to correlate the nodes exporting and collecting resources."
  (query-to-vec (str "SELECT DISTINCT exporters.type, exporters.title, "
                     "(SELECT certname FROM certname_catalogs WHERE catalog=exporters.catalog) AS exporter, "
                     "(SELECT certname FROM certname_catalogs WHERE catalog=collectors.catalog) AS collector "
                     "FROM catalog_resources exporters, catalog_resources collectors "
                     "WHERE exporters.resource=collectors.resource AND exporters.exported=true AND collectors.exported=false "
                     "ORDER BY exporters.type, exporters.title, exporter, collector ASC")))

(ns com.puppetlabs.cmdb.query.population
  (:use [com.puppetlabs.jdbc :only [query-to-vec]]))

(defn correlate-exported-resources
  "Fetch a map of {exported-resource [#{exporting-nodes} #{collecting-nodes}]},
  to correlate the nodes exporting and collecting resources."
  []
  (query-to-vec (str "SELECT DISTINCT exporters.type, exporters.title, "
                     "(SELECT certname FROM certname_catalogs WHERE catalog=exporters.catalog) AS exporter, "
                     "(SELECT certname FROM certname_catalogs WHERE catalog=collectors.catalog) AS collector "
                     "FROM catalog_resources exporters, catalog_resources collectors "
                     "WHERE exporters.resource=collectors.resource AND exporters.exported=true AND collectors.exported=false "
                     "ORDER BY exporters.type, exporters.title, exporter, collector ASC")))

Move docstring to proper location
Move docstring to proper location

kbarber/puppetdb,ajroetker/puppetdb,puppetlabs/puppetdb,grimradical/puppetdb,jantman/puppetdb,github/puppetlabs-puppetdb,mullr/puppetdb,wkalt/puppetdb,highb/puppetdb,johnduarte/puppetdb,puppetlabs/puppetdb,senior/puppetdb,johnduarte/puppetdb,rbrw/puppetdb,shrug/puppetdb,github/puppetlabs-puppetdb,shrug/puppetdb,puppetlabs/puppetdb,jantman/puppetdb,melissa/puppetdb,highb/puppetdb,stahnma/puppetdb,shrug/puppetdb,kbarber/puppetdb,haus/puppetdb,waynr/puppetdb,mullr/puppetdb,wkalt/puppetdb,cprice404/puppetdb,grimradical/puppetdb,ajroetker/puppetdb,johnduarte/puppetdb,highb/puppetdb,kbrezina/puppetdb,senior/puppetdb,senior/puppetdb,mullr/puppetdb,kbrezina/puppetdb,waynr/puppetdb,wkalt/puppetdb,kbrezina/puppetdb,mullr/puppetdb,waynr/puppetdb,nfagerlund/puppetdb,nfagerlund/puppetdb,rbrw/puppetdb,senior/puppetdb,rbrw/puppetdb,rbrw/puppetdb,shrug/puppetdb,wkalt/puppetdb,haus/puppetdb,grimradical/puppetdb,puppetlabs/puppetdb,ajroetker/puppetdb,haus/puppetdb,jantman/puppetdb,grimradical/puppetdb,cprice404/puppetdb,highb/puppetdb,kbarber/puppetdb,puppetlabs/puppetdb,github/puppetlabs-puppetdb,cprice404/puppetdb,melissa/puppetdb,kbarber/puppetdb,kbrezina/puppetdb,stahnma/puppetdb,stahnma/puppetdb,johnduarte/puppetdb,nfagerlund/puppetdb,mullr/puppetdb,melissa/puppetdb,waynr/puppetdb,rbrw/puppetdb,ajroetker/puppetdb