looking good.
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
(map db->clj (j/query conn "SELECT * FROM invoices")))
|
||||
|
||||
|
||||
(defn get-unpaid []
|
||||
(map db->clj (j/query conn "SELECT * FROM invoices WHERE imported=true")))
|
||||
|
||||
(defn get-pending []
|
||||
(println conn)
|
||||
(map db->clj (j/query conn "SELECT * FROM invoices WHERE imported=0")))
|
||||
(map db->clj (j/query conn "SELECT * FROM invoices WHERE imported=false or imported is null")))
|
||||
|
||||
@@ -21,14 +21,19 @@
|
||||
[(keyword (kebab->snake (name k))) v])
|
||||
x)))
|
||||
|
||||
(def conn {:classname "org.postgresql.Driver" ; must be in classpath
|
||||
:dbtype "postgresql"
|
||||
:ssl true
|
||||
:sslfactory "org.postgresql.ssl.NonValidatingFactory"
|
||||
:host "ec2-54-235-123-153.compute-1.amazonaws.com"
|
||||
:port 5342
|
||||
:dbname "dbfemhppkdksfp"
|
||||
; Any additional keys are passed to the driver
|
||||
(let [db-host "ec2-54-235-123-153.compute-1.amazonaws.com"
|
||||
db-port 5432
|
||||
db-name "dbfemhppkdksfp"]
|
||||
|
||||
(def conn {:classname "org.postgresql.Driver" ; must be in classpath
|
||||
:ssl true
|
||||
:sslfactory "org.postgresql.ssl.NonValidatingFactory"
|
||||
:subprotocol "postgresql"
|
||||
:subname (str "//" db-host ":" db-port "/" db-name)
|
||||
; Any additional
|
||||
; keys are passed
|
||||
; to the driver
|
||||
; as driver-specific properties.
|
||||
:user "tkilrhrhzlumol"
|
||||
:password "de6117f8551364ac84ed31c1231941f53ab0b5470c9956f478b2025ab5a0fb8b"})
|
||||
:user "tkilrhrhzlumol"
|
||||
:password "de6117f8551364ac84ed31c1231941f53ab0b5470c9956f478b2025ab5a0fb8b"}))
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
:body (pr-str (invoices/get-all))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
|
||||
(GET "/api/invoices/unpaid" []
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-unpaid))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
|
||||
(GET "/api/invoices/pending" []
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-pending))
|
||||
@@ -33,12 +38,13 @@
|
||||
(POST "/pdf-upload"
|
||||
{{ files "file"} :params :as params}
|
||||
(let [{:keys [filename tempfile]} files]
|
||||
(for [{:keys [total date invoice-number customer-identifier]}
|
||||
(parse/parse-file (.getPath tempfile))]
|
||||
{"customer-identifier" customer-identifier
|
||||
"invoice-number" invoice-number
|
||||
"date" date
|
||||
"total" total})))
|
||||
(invoices/insert-multi!
|
||||
(for [{:keys [total date invoice-number customer-identifier] :as row}
|
||||
(parse/parse-file (.getPath tempfile))]
|
||||
(assoc row :imported false)))
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-pending))
|
||||
:headers {"Content-Type" "application/edn"}}))
|
||||
(route/resources "/")
|
||||
(routes (ANY "*" [] (response/resource-response "index.html" {:root "public"})))
|
||||
(route/not-found "Not Found"))
|
||||
|
||||
Reference in New Issue
Block a user