       (response {:status 403
                  :body {:error (str "The team named '" team-name "' did not exist")}}))))
 
-(defn delete-team [{:keys [team-name]}]
+(defn delete-team 
+  "Deletes a team provided the team exists"
+  [{:keys [team-name]}]
   (let [rows-aff (delete-team! db team-name)]
     (if (= 1 rows-aff)
       (response {:status 200

(defquery update-team-presentation! "sql/update-team-pres-score.sql")
(defquery delete-team! "sql/delete-team.sql")

(defn teams-summary []
  {:body (select-summary db)})

(defn results-summary []
  {:body (select-results db)}) 

(defn create-team [{:keys [team-name]}]
  (let [rows-aff (create-team! db team-name)]
    (if (= 1 rows-aff)
      (response {:status 200

      (response {:status 403
                 :body {:error (str "The team '" team-name "' already exists")}}))))

(defn update-by-field 
  "Helper function to update correct field of team"
  [team-name field value]
  (cond
    (= field "Weight") (update-team-weight! db value team-name)
    (= field "Launch") (update-team-launch! db value team-name)
    (= field "Ramp") (update-team-ramp! db value team-name)
    (= field "Presentation") (update-team-presentation! db value team-name)))

(defn update-team 
  "Updates team field, weight or score, to new value provided the team exists"
  [{:keys [team-name field value]}]
  (let [rows-aff (update-by-field team-name field value)]
    (if (= 1 rows-aff)
      (response {:status 200
