 (require '[zg.format-date :as format-date])
 
 (defn status->int
+    "Convert word status (:deleted, :undeleted) into an integer."
     [status]
     (if (= status :deleted)
         1
         0))
 
 (defn dictionary-type->char
+    "Convert dictionary type (:whitelist, :blacklist) into an integer."
     [dictionary-type]
     (condp = dictionary-type
         :whitelist "w"


(defn insert-word-into-dictionary
    "Try to insert new word into the dictionary. If insert fails, exception
     is thrown and needs to be caught outside this function."
    [word description user-name dictionary-type datetime]
    (jdbc/insert! db-spec/zg-db
        :dictionary {:word       word

                        (println e))))))))

(defn set-word-status
    "Set or change status of given word in the dictionary (:deleted, :undeleted)."
    [word dictionary-type status]
    (try
        (jdbc/update! db-spec/zg-db
                      :dictionary {:deleted (status->int status)}
                                   ["word = ? and dictionary = ?" word (dictionary-type->char dictionary-type)])
        (catch Exception e
            (println e)
            [])))
