diff options
Diffstat (limited to 'src/controller')
| -rw-r--r-- | src/controller/routes.phel | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/controller/routes.phel b/src/controller/routes.phel index 7e1cde8..f6ec95e 100644 --- a/src/controller/routes.phel +++ b/src/controller/routes.phel @@ -22,11 +22,13 @@ (defn book-create-handler [request] (let [title (get-in request [:parsed-body "title"]) subtitle (get-in request [:parsed-body "subtitle"]) - authors (str/split (get-in request [:parsed-body "author"]) #",")] + authors (str/split (get-in request [:parsed-body "author"]) #",") + pages (get-in request [:parsed-body "pages"])] (pdo/with-transaction conn (let [time (php/time) book-id (pdo/insert conn :books {:title title :subtitle subtitle + :pages pages :created_at time :updated_at time})] (for [a :in authors] @@ -39,6 +41,7 @@ (defn book-session-create-handler [request] (let [id (get-in request [:attributes :match :path-params :id]) + pages (pdo/fetch-column (pdo/query conn "select pages from books where id = :id" {:id id})) time (php/time)] (pdo/with-transaction conn (let [session-id (pdo/insert conn :books_sessions {:book_id id @@ -48,7 +51,7 @@ :updated_at time})] (pdo/insert conn :sessions_progress {:session_id session-id :progress 0 - :total 0 + :total pages :created_at time :updated_at time})))) (h/response-from-map {:status 301 :headers {:location "/"}})) |
