performance optimization, much faster when only looking up check if transaction not found.

This commit is contained in:
Bryce Covert
2020-12-08 20:43:27 -08:00
parent 65ac96b8a4
commit 99b6d822f6
2 changed files with 34 additions and 33 deletions

View File

@@ -92,7 +92,7 @@
client (:client/_bank-accounts bank-account) client (:client/_bank-accounts bank-account)
client-id (:db/id client) client-id (:db/id client)
valid-locations (or (:bank-account/locations bank-account) (:client/locations client)) valid-locations (or (:bank-account/locations bank-account) (:client/locations client))
check (transaction->payment transaction check-number client-id bank-account-id amount id)
date (time/parse date "YYYY-MM-dd")] date (time/parse date "YYYY-MM-dd")]
:when (and client-id :when (and client-id
(not (existing (sha-256 (str id)))) (not (existing (sha-256 (str id))))
@@ -101,38 +101,39 @@
(or (not (:start-date bank-account)) (or (not (:start-date bank-account))
(t/after? date (:start-date bank-account))) (t/after? date (:start-date bank-account)))
)] )]
(-> (let [check (transaction->payment transaction check-number client-id bank-account-id amount id)]
#:transaction (->
{:post-date (coerce/to-date (time/parse post-date "YYYY-MM-dd")) #:transaction
:id (sha-256 (str id)) {:post-date (coerce/to-date (time/parse post-date "YYYY-MM-dd"))
:account-id account-id :id (sha-256 (str id))
:date (coerce/to-date date) :account-id account-id
:amount (double amount) :date (coerce/to-date date)
:description-original (some-> description-original (str/replace #"\s+" " ")) :amount (double amount)
:description-simple (some-> description-simple (str/replace #"\s+" " ")) :description-original (some-> description-original (str/replace #"\s+" " "))
:approval-status (if check :description-simple (some-> description-simple (str/replace #"\s+" " "))
:transaction-approval-status/approved :approval-status (if check
:transaction-approval-status/unapproved) :transaction-approval-status/approved
:type type :transaction-approval-status/unapproved)
:status status :type type
:client client-id :status status
:check-number check-number :client client-id
:bank-account bank-account-id :check-number check-number
:payment (when check :bank-account bank-account-id
{:db/id (:db/id check) :payment (when check
:payment/status :payment-status/cleared}) {:db/id (:db/id check)
:payment/status :payment-status/cleared})
:vendor (when check :vendor (when check
(:db/id (:payment/vendor check))) (:db/id (:payment/vendor check)))
:location (when check :location (when check
"A") "A")
:accounts (when check :accounts (when check
[#:transaction-account {:account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"])) [#:transaction-account {:account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"]))
:location "A" :location "A"
:amount (Math/abs (double amount))}])} :amount (Math/abs (double amount))}])}
(apply-rules valid-locations) (apply-rules valid-locations)
remove-nils)))) remove-nils)))))
(defn batch-transact [transactions] (defn batch-transact [transactions]

View File

@@ -83,8 +83,8 @@ resource "aws_lb_target_group" "integreat_app" {
path = "/api/health-check" path = "/api/health-check"
port = "traffic-port" port = "traffic-port"
protocol = "HTTP" protocol = "HTTP"
timeout = 5 timeout = 14
unhealthy_threshold = 2 unhealthy_threshold = 5
} }
stickiness { stickiness {