(cloud) big performance improvements for page load.

This commit is contained in:
2023-04-06 14:38:22 -07:00
parent 2a0f736af7
commit 5561861d3d
10 changed files with 349 additions and 272 deletions

View File

@@ -699,15 +699,14 @@
(- (+ total credit)
debit))
0.0
(dc/q {:query {:find '[?debit ?credit]
:in '[$ ?client]
:where ['[?j :journal-entry/client ?client]
'[?j :journal-entry/line-items ?je]
'[?je :journal-entry-line/account ?ba]
'[?ba :bank-account/type :bank-account-type/check]
'[(get-else $ ?je :journal-entry-line/debit 0.0) ?debit]
'[(get-else $ ?je :journal-entry-line/credit 0.0) ?credit]]}
:args [(dc/db conn) client_id]}))
(dc/q {:query {:find '[?debit ?credit]
:in '[$ ?client]
:where ['[?client :client/bank-accounts ?ba]
'[?ba :bank-account/type :bank-account-type/check]
'[?je :journal-entry-line/account ?ba]
'[(get-else $ ?je :journal-entry-line/debit 0.0) ?debit]
'[(get-else $ ?je :journal-entry-line/credit 0.0) ?credit]]}
:args [(dc/db conn) client_id]}))
bills-due-soon (dc/q {:query {:find '[?due ?outstanding ?invoice-number ?vendor-id ?vendor-name]
:in '[$ ?client ?due-before]
:where ['[?i :invoice/client ?client]
@@ -734,8 +733,8 @@
recent-fulfillments (dc/q {:query {:find '[?f ?d]
:in '[$ ?client ?min-date]
:where ['[?t :transaction/forecast-match ?f]
'[?t :transaction/date ?d]
'[?t :transaction/client ?client]
'[?t :transaction/date ?d]
'[(>= ?d ?min-date)]]}
:args [(dc/db conn) client_id (coerce/to-date (t/plus (time/local-now) (t/months -2)))]})
forecasted-transactions (for [{:forecasted-transaction/keys [amount identifier day-of-month]