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

                          (assoc :subject {:title (:containing_class result)})
                          (dissoc :containing_class))))

(defn- create-subject-maps
  "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 results]
  {:pre [(vector? results)]
   :post [(vector? %)]}
  (mapv (partial create-subject-map summarize-by) results))

(defn query->sql
  "Convert an event-counts `query` and a value to `summarize-by` into a SQL string.

    (format "SELECT * FROM (%s) count_results WHERE %s" sql where)
    sql))

(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]
