   (database mysql-db))
 
 
-(defn random-world []
+(defn random-world
   "Query a random World record from the database"
+  []
   (let [id (inc (rand-int 9999))] ; Num between 1 and 10,000
     (select world
-      (where {:id id }))))
+            (where {:id id }))))
 
 
 (defn run-queries


(defn sanitizeQueriesParam
  "Sanitizes the `queries` parameter. Caps the value between 1 and 500.
Invalid (stringy) values become 1"
  [request]
  (let [queries (-> request :params :queries)]
    (let [n
      (if (= (re-find #"\A-?\d+" queries) nil)
        1
        (Integer/parseInt queries))]
    (cond
      (< n 1) 1
      (> n 500) 500
      :else n))))


(defn multiple-query-test
  "Test 3: Multiple database queries"
  [request]
  (-> request
    (sanitizeQueriesParam)
    (run-queries)
    (bootstrap/json-response)))


; Set up entity Fortune and the database representation

  (database mysql-db))


(defn get-all-fortunes
  "Query all Fortune records from the database."
  []
  (select fortune
          (fields :id :message)))


(defn get-fortunes
  "Fetch the full list of Fortunes from the database, sort them by the fortune
  message text, and then return the results."
  []
  (sort-by #(:message %)
    (conj
      (get-all-fortunes)
      { :id 0 :message "Additional fortune added at request time." })))


(defn fortunes-hiccup
  "Render the given fortunes to simple HTML using Hiccup."
  [fortunes]
  (html5
   [:head
    [:title "Fortunes"]]
