speeds up

This commit is contained in:
2024-02-08 21:05:37 -08:00
parent 487a171693
commit f48c819a96

View File

@@ -6,6 +6,7 @@
[auto-ap.datomic.accounts :as d-accounts]
[auto-ap.datomic.transactions :as d-transactions]
[auto-ap.graphql.utils :refer [extract-client-ids]]
[auto-ap.logging :as alog]
[auto-ap.query-params :as query-params]
[auto-ap.routes.admin.transaction-rules :as route]
[auto-ap.routes.utils
@@ -20,15 +21,13 @@
[auto-ap.ssr.form-cursor :as fc]
[auto-ap.ssr.grid-page-helper :as helper]
[auto-ap.ssr.hx :as hx]
[auto-ap.ssr.nested-form-params :refer [wrap-nested-form-params]]
[auto-ap.ssr.svg :as svg]
[auto-ap.ssr.utils
:refer [apply-middleware-to-all-handlers entity-id
field-validation-error form-validation-error
html-response main-transformer many-entity modal-response
money percentage ref->enum-schema ref->radio-options
regex temp-id wrap-entity wrap-form-4xx-2
wrap-schema-enforce]]
html-response many-entity modal-response money percentage
ref->enum-schema ref->radio-options regex temp-id
wrap-entity wrap-schema-enforce]]
[auto-ap.time :as atime]
[auto-ap.utils :refer [dollars=]]
[bidi.bidi :as bidi]
@@ -307,15 +306,19 @@
:in ['$ 'read]
:where []}
:args [(dc/db conn) transaction-read]}
only-uncoded?
(merge-query {:query {:where ['[?e :transaction/approval-status :transaction-approval-status/unapproved]]}})
(not only-uncoded?)
(merge-query {:query {:where '[[(iol-ion.query/recent-date 60) ?start-date]
[?e :transaction/date ?d]
[(>= ?d ?start-date)]]}})
description
(merge-query {:query {:in ['?descr]
:where ['[(iol-ion.query/->pattern ?descr) ?description-regex]]}
:args [description]})
client-group
(merge-query {:query {:in ['?client-group]
:where ['[?e :transaction/client ?client-group-client]
'[?client-group-client :client/groups ?client-group]]}
:args [client-group]})
valid-clients
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :transaction/client ?xx]]}
@@ -330,6 +333,12 @@
(merge-query {:query {:where ['[?e :transaction/description-original ?do]
'[(re-find ?description-regex ?do)]]}})
client-group
(merge-query {:query {:in ['?client-group]
:where ['[?e :transaction/client ?client-group-client]
'[?client-group-client :client/groups ?client-group]]}
:args [client-group]})
amount-gte
(merge-query {:query {:in ['?amount-gte]
:where ['[?e :transaction/amount ?ta]
@@ -356,12 +365,11 @@
'[(>= ?dom ?dom-gte)]]}
:args [dom-gte]})
only-uncoded?
(merge-query {:query {:where ['[or [?e :transaction/approval-status :transaction-approval-status/unapproved]
[(missing? $ ?e :transaction/approval-status)]]]}})
true
(merge-query {:query {:where ['[?e :transaction/id]]}}))
_ (alog/peek query)
results (->>
(query2 query)
(map first))]