     (vec sorted)))
 
 (defn- post-process-results
-  "TODO docs & conditions"
+  "Given the results of the query and the optional order-by paging clauses,
+  consolidate the results into a form appropriate for returning to the user
+  and sort them based on the order-by clauses, if there are any."
   [query-results {:keys [order-by]}]
-  (let [aggregated-results (aggregate-resource-parameters query-results)]
+  {:pre  [(vector? query-results)
+          ((some-fn nil? vector?) order-by)
+          (every? map? order-by)]
+   :post [(vector? %)]}
+  (let [consolidated-results (consolidate-resource-params query-results)]
     (if (empty? order-by)
-      aggregated-results
-      (sort-on-order-by aggregated-results order-by))))
+      consolidated-results
+      (sort-on-order-by consolidated-results order-by))))
 
 (defn limited-query-resources
   "Take a limit, a map of paging options, and a map of SQL queries as

(def v3-query->sql
  (partial query->sql resource-operators-v3))

(defn- aggregate-resource-parameters
  "TODO docs & conditions"
  [query-results]
  (let [metadata_cols [:certname :resource :type :title :tags :exported :file :line]
        metadata      (apply juxt metadata_cols)

        val1))))

(defn- sort-on-order-by
  "Sort the results of the query based on the order by clauses."
  [query-results order-bys]
  {:pre  [(vector? query-results)
          (vector? order-bys)
          (every? map? order-bys)]
   :post [(vector? %)
          (= (count %)
             (count query-results))]}
  (let [order-bys  (mapv #(update-in % [:field] keyword) order-bys)
        comp-fns   (map build-comp-fn order-bys)
        final-comp (reduce combine-comp-fns comp-fns)
