 (hugsql/def-db-fns "akvo/lumen/lib/visualisation.sql")
 
 
-(defn dashboard-spec [v1-id v2-id]
+(defn dashboard-spec [v1-id v2-id ds]
   (w/keywordize-keys
    {"type"     "dashboard"
     "title"    "My first Dashboard"

                "text-2" {"id"      "text-2"
                          "type"    "text"
                          "content" "I am another text entity."}}
    "layout"   {v1-id    {"x" 1
                          "y" 0
                          "w" 0

                                                        :with-job? true
                                                        :data data})
        dataset-id (:dataset_id job)
        dataset    (last (ds/fetch-metadata conn dataset-id))
        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 :dataset dataset}))

(defn seed
  [conn spec]
  (let [res1 (seed* conn (:vis-1 spec))
        res2 (seed* conn (:vis-2 spec))
        dash-res (dashboard/create conn (dashboard-spec (:id (:vis-1 spec))
                                                        (:id (:vis-2 spec))
                                                        (:dataset res1))
                                   {})]
    {:seed-1 res1 :seed-2 res2 :dashboard dash-res}))

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