 (ns akvo.lumen.lib.transformation.engine
-  (:require [akvo.lumen.lib :as lib]
-            [akvo.lumen.util :as util]
+  (:require [akvo.lumen.util :as util]
             [akvo.lumen.db.transformation :as db.transformation]
             [akvo.lumen.db.dataset-version :as db.dataset-version]
             [clojure.set :as set]

            (db.dataset-version/new-dataset-version tenant-conn
                                 next-dataset-version)
            (db.transformation/touch-dataset tenant-conn {:id dataset-id})
            (db.transformation/drop-table tenant-conn {:table-name previous-table-name})
            (lib/created next-dataset-version)))
        (let [transformation (assoc (first transformations) :dataset-id dataset-id)
              {:keys [success? message columns execution-log] :as transformation-result}
              (try-apply-operation deps table-name columns transformation)]


(defn execute-undo [{:keys [tenant-conn] :as deps} dataset-id job-execution-id]
  (let [current-dataset-version (db.transformation/latest-dataset-version-by-dataset-id tenant-conn
                                                                      {:dataset-id dataset-id})]
    (when (not= (:version current-dataset-version) 1)
      (apply-undo deps
                  dataset-id
                  job-execution-id
