summaryrefslogtreecommitdiff
path: root/src/chef/logic/recipes.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/chef/logic/recipes.clj')
-rw-r--r--src/chef/logic/recipes.clj11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/chef/logic/recipes.clj b/src/chef/logic/recipes.clj
index 1fd1db5..8612948 100644
--- a/src/chef/logic/recipes.clj
+++ b/src/chef/logic/recipes.clj
@@ -3,16 +3,19 @@
[clojure.string :as cstr]
[honey.sql :as sql]
[next.jdbc :as jdbc]
- [chef.database :as cdb])
+ [chef.database :as cdb]
+ [chef.utils :as cutils])
(:import java.io.File))
(defn get-all-recipes []
+ (cutils/dprintln "get-all-recipes")
(->> {:select [:*]
:from [:recipes]}
sql/format
(jdbc/execute! @cdb/db)))
(defn get-recipe [id]
+ (cutils/dprintln "get-recipe")
(->> {:select [:*]
:from [:recipes]
:where [:= :id id]}
@@ -21,18 +24,21 @@
first))
(defn create-recipe! []
+ (cutils/dprintln "create-recipe!")
(->> {:insert-into [:recipes]
:values [{:title "New recipe"}]}
sql/format
(jdbc/execute! @cdb/db)))
(defn delete-recipe! [id]
+ (cutils/dprintln "delete-recipe!")
(->> {:delete-from [:recipes]
:where [:= :id id]}
sql/format
(jdbc/execute! @cdb/db)))
(defn update-recipe! [id updates]
+ (cutils/dprintln "update-recipe!")
(->> {:update :recipes
:set updates
:where [:= :id id]}
@@ -40,6 +46,7 @@
(jdbc/execute! @cdb/db)))
(defn get-recipe-thumbnail [recipe-id]
+ (cutils/dprintln "get-recipe-thumbnail")
(let [thumbnails-folder (File. "./thumbnails/")]
(->> thumbnails-folder
.listFiles
@@ -48,10 +55,12 @@
first)))
(defn remove-recipe-thumbnail! [id]
+ (cutils/dprintln "remove-recipe-thumbnail!")
(when-let [file (get-recipe-thumbnail id)]
(.delete ^File file)))
(defn set-recipe-thumbnail! [id multipart-param]
+ (cutils/dprintln "set-recipe-thumbnail!")
(when-let [existing-thumbnail-file (get-recipe-thumbnail id)]
(.delete ^File existing-thumbnail-file))
(cjio/copy (:tempfile multipart-param)