     (format "SELECT * FROM (%s) count_results WHERE %s" sql where)
     sql))
 
-(defn- create-subject-map
+(defn- munge-subject
   "Helper function to transform the event count subject data from the raw format that we get back from the
   database into the more structured format that the API specifies."
   [summarize-by result]

    (update-in
      (execute-query (apply vector sql params) paging-options)
      [:result]
      (partial create-subject-maps summarize-by))))

           (contains? result :certname)
           (every? #(contains? result %) [:resource_type :resource_title])
           (contains? result :containing_class))]
   :post [(map? %)
          (not (contains-some % [:certname :resource_type :resource_title :containing_class]))
          (map? (:subject %))
          (= summarize-by (:subject-type %))]}
  (condp = summarize-by
    "node"              (-> result
                          (assoc :subject-type "node")
