 (ns akvo.lumen.endpoint.share-test
   {:functional true}
-  (:require [akvo.lumen.fixtures :refer [*tenant-conn*
+  (:require [akvo.lumen.endpoint.commons.variant :as variant]
+            [akvo.lumen.fixtures :refer [*tenant-conn*
                                          tenant-conn-fixture
                                          system-fixture]]
             [akvo.lumen.lib.dashboard :as dashboard]
+            [akvo.lumen.lib.dataset :as ds]
             [akvo.lumen.lib.share :as share]
+            [akvo.lumen.test-utils :as tu]
             [akvo.lumen.util :refer [gen-table-name squuid]]
-            [akvo.lumen.endpoint.commons.variant :as variant]
+            [clojure.java.jdbc :as jdbc]
+            [clojure.test :refer :all]
+            [clojure.tools.logging :as log]
             [clojure.walk :as w]
-            [clojure.java.jdbc :as jdbc]
-            [akvo.lumen.test-utils :as tu]
-            [clojure.test :refer :all]
             [hugsql.core :as hugsql]))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                                        :with-job? true
                                                        :data data})
        dataset-id (:dataset_id job)
        data-source-id (:data_source_id job)]

    (upsert-visualisation conn (merge vis-spec {:dataset-id dataset-id}))
    {:visualisation-id (:id vis-spec) :dataset-id dataset-id :data-source-id data-source-id}))

(defn seed
  [conn spec]
  (seed* conn (:vis-1 spec))
  (seed* conn (:vis-2 spec))
  (dashboard/create conn (dashboard-spec (:id (:vis-1 spec))
                                         (:id (:vis-2 spec))) {}))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Test data

(hugsql/def-db-fns "akvo/lumen/lib/visualisation.sql")


(defn dashboard-spec [v1-id v2-id ds]
  (w/keywordize-keys
   {"type"     "dashboard"
    "title"    "My first Dashboard"
