Fixing export bugs with bad queries, improving performance.
This commit is contained in:
@@ -28,19 +28,7 @@
|
||||
:in ['$]
|
||||
:where ['[?e :invoice/invoice-number]]}
|
||||
:args [(d/db (d/connect uri))]}
|
||||
(:sort args) (add-sorter-fields {"client" ['[?e :invoice/client ?c]
|
||||
'[?c :client/name ?sort-client]]
|
||||
"vendor" ['[?e :invoice/vendor ?v]
|
||||
'[?v :vendor/name ?sort-vendor]]
|
||||
"description-original" ['[?e :transaction/description-original ?sort-description-original]]
|
||||
"location" ['[?e :invoice/expense-accounts ?iea]
|
||||
'[?iea :invoice-expense-account/location ?sort-location]]
|
||||
"date" ['[?e :invoice/date ?sort-date]]
|
||||
"due" ['[?e :invoice/due ?sort-due]]
|
||||
"invoice-number" ['[?e :invoice/invoice-number ?sort-invoice-number]]
|
||||
"total" ['[?e :invoice/total ?sort-total]]
|
||||
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
|
||||
args)
|
||||
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :invoice/client ?xx]]}
|
||||
@@ -92,9 +80,23 @@
|
||||
:where ['[?e :invoice/invoice-number ?invoice-number]
|
||||
'[(.contains ^String ?invoice-number ?invoice-number-like)]]}
|
||||
:args [(:invoice-number-like args)]})
|
||||
|
||||
(:sort args) (add-sorter-fields {"client" ['[?e :invoice/client ?c]
|
||||
'[?c :client/name ?sort-client]]
|
||||
"vendor" ['[?e :invoice/vendor ?v]
|
||||
'[?v :vendor/name ?sort-vendor]]
|
||||
"description-original" ['[?e :transaction/description-original ?sort-description-original]]
|
||||
"location" ['[?e :invoice/expense-accounts ?iea]
|
||||
'[?iea :invoice-expense-account/location ?sort-location]]
|
||||
"date" ['[?e :invoice/date ?sort-date]]
|
||||
"due" ['[?e :invoice/due ?sort-due]]
|
||||
"invoice-number" ['[?e :invoice/invoice-number ?sort-invoice-number]]
|
||||
"total" ['[?e :invoice/total ?sort-total]]
|
||||
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
|
||||
args)
|
||||
true
|
||||
(merge-query {:query {:find ['?base-date '?e]
|
||||
:where ['[?e :invoice/date ?base-date]]}}) )
|
||||
(merge-query {:query {:find ['?e]
|
||||
:where ['[?e :invoice/client]]}}) )
|
||||
(d/query)
|
||||
(apply-sort-3 args)
|
||||
(apply-pagination args)))
|
||||
|
||||
@@ -25,25 +25,7 @@
|
||||
:where []}
|
||||
:args [db]}
|
||||
|
||||
(:sort args) (add-sorter-fields {"client" ['[?e :transaction/client ?c]
|
||||
'[?c :client/name ?sort-client]]
|
||||
"account" ['[?e :transaction/date]
|
||||
'(or-join [?e ?sort-account]
|
||||
(and [?e :transaction/account ?c]
|
||||
[?c :account/name ?sort-account])
|
||||
(and
|
||||
(not [?e :transaction/account])
|
||||
[(ground "") ?sort-account]))]
|
||||
"description-original" ['[?e :transaction/description-original ?sort-description-original]]
|
||||
"date" ['[?e :transaction/date ?sort-date]]
|
||||
"vendor" ['(or-join [?e ?sort-vendor]
|
||||
(and [(missing? $ ?e :transaction/vendor)]
|
||||
[?e :transaction/description-original ?sort-vendor])
|
||||
(and [?e :transaction/vendor ?v]
|
||||
[?v :vendor/name ?sort-vendor]))]
|
||||
"amount" ['[?e :transaction/amount ?sort-amount]]
|
||||
"status" ['[?e :transaction/status ?sort-status]]}
|
||||
args)
|
||||
|
||||
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
@@ -113,9 +95,28 @@
|
||||
'[(.contains ?do ?description)]]}
|
||||
:args [(:description args)]})
|
||||
|
||||
(:sort args) (add-sorter-fields {"client" ['[?e :transaction/client ?c]
|
||||
'[?c :client/name ?sort-client]]
|
||||
"account" ['[?e :transaction/date]
|
||||
'(or-join [?e ?sort-account]
|
||||
(and [?e :transaction/account ?c]
|
||||
[?c :account/name ?sort-account])
|
||||
(and
|
||||
(not [?e :transaction/account])
|
||||
[(ground "") ?sort-account]))]
|
||||
"description-original" ['[?e :transaction/description-original ?sort-description-original]]
|
||||
"date" ['[?e :transaction/date ?sort-date]]
|
||||
"vendor" ['(or-join [?e ?sort-vendor]
|
||||
(and [(missing? $ ?e :transaction/vendor)]
|
||||
[?e :transaction/description-original ?sort-vendor])
|
||||
(and [?e :transaction/vendor ?v]
|
||||
[?v :vendor/name ?sort-vendor]))]
|
||||
"amount" ['[?e :transaction/amount ?sort-amount]]
|
||||
"status" ['[?e :transaction/status ?sort-status]]}
|
||||
args)
|
||||
true
|
||||
(merge-query {:query {:find ['?base-date '?e] :where ['[?e :transaction/id]
|
||||
'[?e :transaction/date ?base-date]]}}))]
|
||||
(merge-query {:query {:find ['?e] :where ['[?e :transaction/id]]}}))
|
||||
_ (println query)]
|
||||
(cond->> query
|
||||
true (d/query)
|
||||
true (apply-sort-3 args)
|
||||
|
||||
Reference in New Issue
Block a user