   ([conn project-name suite-name]
     (get-suite-by-name conn project-name suite-name identity))
   ([conn project-name suite-name row-fn]
-    (first (j/query conn
-             ["SELECT suite.* FROM suite JOIN project ON project_id = project.id WHERE project.name = ? AND suite.name = ?" project-name suite-name]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn
+      ["SELECT suite.* FROM suite JOIN project ON project_id = project.id WHERE project.name = ? AND suite.name = ?" project-name suite-name]
+      :row-fn row-fn)))
 
 (defn get-suite-by-id
   ([conn project-id suite-id]
     (get-suite-by-id conn project-id suite-id identity))
   ([conn project-id suite-id row-fn]
-    (first (j/query conn
-             ["SELECT suite.* FROM suite JOIN project ON suite.project_id = project.id WHERE suite.id = ? AND project.id = ?" suite-id project-id]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn
+      ["SELECT suite.* FROM suite JOIN project ON suite.project_id = project.id WHERE suite.id = ? AND project.id = ?" suite-id project-id]
+      :row-fn row-fn)))
 
 (defn get-project-by-name
   ([conn project-name]
     (get-project-by-name conn project-name identity))
   ([conn project-name row-fn]
-    (first (j/query conn
-             ["SELECT * FROM project WHERE name = ?" project-name]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn ["SELECT * FROM project WHERE name = ?" project-name] :row-fn row-fn)))
 
 (defn get-project-by-id
   ([conn project-id]
     (get-project-by-id conn project-id identity))
   ([conn project-id row-fn]
-    (first (j/query conn
-             ["SELECT project.* FROM project WHERE id = ?" project-id]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn ["SELECT project.* FROM project WHERE id = ?" project-id] :row-fn row-fn)))
 
 (defn create-suite-for-project!
   "Creates a new suite with an empty baseline for the given project. Returns the created suite's id."

                 safter.os after_os,
                 safter.screenshot_name after_name,
                 safter.path after_path FROM analysis
    JOIN diff ON diff.analysis_id = analysis.id
    JOIN diff_image ON diff.diff_image = diff_image.id
    JOIN screenshot safter ON safter.id = diff.after
    JOIN screenshot sbefore ON sbefore.id = diff.before
    WHERE analysis.run_id = ?" run-id]
                :row-fn format-dates
                :identifiers ident-fn
                :result-set-fn vec)]
    {:analysis analysis :diffs diffs}))



;; Baseline
(defn get-baseline-screenshot [conn suite-id screenshot-name {:keys [os browser resolution]}]
  (query-single conn
    ["SELECT screenshot.* FROM screenshot
                 JOIN baseline_screenshot ON screenshot.id = baseline_screenshot.screenshot_id
                 JOIN baseline ON baseline_screenshot.baseline_id = baseline.id
                 JOIN suite ON baseline.suite_id = suite.id
                 WHERE suite.id = ? AND screenshot.screenshot_name = ?
                 AND screenshot.os = ? AND screenshot.resolution = ?
                 AND screenshot.browser = ?" suite-id screenshot-name os resolution browser]))

(defn get-baseline [conn suite-id]
  (query-single conn ["SELECT * FROM baseline WHERE suite_id = ?" suite-id]))

(defn create-baseline-screenshot!
  "Adds the given screenshot-id to the given baseline."
