 (ns metabase.api.card
   (:require [clojure.data :as data]
             [compojure.core :refer [GET POST DELETE PUT]]
-            [korma.core :as k]
-            [metabase.events :as events]
+            [honeysql.helpers :as h]
             [metabase.api.common :refer :all]
-            [metabase.db :refer :all]
+            (metabase [db :as db]
+                      [events :as events])
             (metabase.models [hydrate :refer [hydrate]]
                              [card :refer [Card] :as card]
                              [card-favorite :refer [CardFavorite]]

   archived               Boolean}
  (let-404 [card (Card id)]
    (write-check card)
    (upd-non-nil-keys Card id
                      :dataset_query          dataset_query
                      :description            description
                      :display                display
                      :name                   name
                      :public_perms           public_perms
                      :visualization_settings visualization_settings
                      :archived               archived)
    (let [event (cond
                  ;; card was archived
                  (and archived

    (checkp (integer? model_id) "id" (format "id is required parameter when filter mode is '%s'" (name f)))
    (case f
      :database (read-check Database model_id)
      :table    (read-check Database (db/select-one-field :db_id Table, :id model_id))))
  (cards-for-filter-option f model_id label))

(defendpoint POST "/"
