Improvements to performance!
This commit is contained in:
@@ -14,28 +14,19 @@
|
|||||||
|
|
||||||
(let [query (cond-> {:query {:find []
|
(let [query (cond-> {:query {:find []
|
||||||
:in ['$ ]
|
:in ['$ ]
|
||||||
:where ['[?e :journal-entry/date ?sort-default]]}
|
:where []}
|
||||||
:args [db]}
|
:args [db]}
|
||||||
|
|
||||||
(:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c]
|
|
||||||
'[?c :client/name ?sort-client]]
|
|
||||||
"date" ['[?e :journal-entry/date ?sort-date]]
|
|
||||||
"vendor" ['[?e :journal-entry/vendor ?sort-vendor]]
|
|
||||||
"amount" ['[?e :journal-entry/amount ?sort-amount]]
|
|
||||||
"external-id" ['[?e :journal-entry/external-id ?sort-external-id]]
|
|
||||||
"source" ['[?e :journal-entry/source ?sort-source]]}
|
|
||||||
args)
|
|
||||||
|
|
||||||
(limited-clients (:id args))
|
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
|
||||||
:where ['[?e :journal-entry/client ?xx]]}
|
|
||||||
:args [(set (map :db/id (limited-clients (:id args))))]})
|
|
||||||
|
|
||||||
(:client-id args)
|
(:client-id args)
|
||||||
(merge-query {:query {:in ['?client-id]
|
(merge-query {:query {:in ['?client-id]
|
||||||
:where ['[?e :journal-entry/client ?client-id]]}
|
:where ['[?e :journal-entry/client ?client-id]]}
|
||||||
:args [(:client-id args)]})
|
:args [(:client-id args)]})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(:only-external args)
|
(:only-external args)
|
||||||
(merge-query {:query {:where ['(not [?e :journal-entry/original-entity ])]}})
|
(merge-query {:query {:where ['(not [?e :journal-entry/original-entity ])]}})
|
||||||
|
|
||||||
@@ -113,10 +104,22 @@
|
|||||||
:where ['[?e :journal-entry/line-items ?li]
|
:where ['[?e :journal-entry/line-items ?li]
|
||||||
'[?li :journal-entry-line/location ?location]]}
|
'[?li :journal-entry-line/location ?location]]}
|
||||||
:args [(:location args)]})
|
:args [(:location args)]})
|
||||||
|
(limited-clients (:id args))
|
||||||
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
|
:where ['[?e :journal-entry/client ?xx]]}
|
||||||
|
:args [(set (map :db/id (limited-clients (:id args))))]})
|
||||||
|
(:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c]
|
||||||
|
'[?c :client/name ?sort-client]]
|
||||||
|
"date" ['[?e :journal-entry/date ?sort-date]]
|
||||||
|
"vendor" ['[?e :journal-entry/vendor ?sort-vendor]]
|
||||||
|
"amount" ['[?e :journal-entry/amount ?sort-amount]]
|
||||||
|
"external-id" ['[?e :journal-entry/external-id ?sort-external-id]]
|
||||||
|
"source" ['[?e :journal-entry/source ?sort-source]]}
|
||||||
|
args)
|
||||||
|
|
||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?sort-default '?e] :where ['[?e :journal-entry/date ?sort-default]]}}))]
|
(merge-query {:query {:find ['?sort-default '?e] :where ['[?e :journal-entry/date ?sort-default]]}}))]
|
||||||
(->> (doto query println)
|
(->> (doto query log/info)
|
||||||
|
|
||||||
(d/query)
|
(d/query)
|
||||||
(apply-sort-3 (update args :sort conj {:sort-key "default-2" :asc true}))
|
(apply-sort-3 (update args :sort conj {:sort-key "default-2" :asc true}))
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
))
|
))
|
||||||
)
|
)
|
||||||
journal-entries)]
|
journal-entries)]
|
||||||
(result->page journal-entries journal-entries-count :journal_entries args)))
|
(result->page journal-entries journal-entries-count :journal_entries (:filters args))))
|
||||||
|
|
||||||
;; TODO a better way to do this might be to accumulate ALL credits and ALL debits, and then just do for credits: balance = credits - debits. and for debits balance = debits - credits
|
;; TODO a better way to do this might be to accumulate ALL credits and ALL debits, and then just do for credits: balance = credits - debits. and for debits balance = debits - credits
|
||||||
(defn credit-account? [account]
|
(defn credit-account? [account]
|
||||||
|
|||||||
Reference in New Issue
Block a user