fixes issues with a neverending search. Also fixes client saving to match normal test.

This commit is contained in:
2023-03-24 13:01:33 -07:00
parent 7fd3528d0f
commit 4f94602716
8 changed files with 112 additions and 87 deletions

View File

@@ -617,6 +617,7 @@
:count (count results)})
(defn audit-transact-batch [txes id]
(println "transacting batch")
(let [batch-id (.toString (java.util.UUID/randomUUID))]
(reduce
(fn [full-tx batch]
@@ -636,7 +637,8 @@
true (update :tempids merge (:tempids tx-result)))))
{}
(partition-all 200 txes))))
(partition-all 200 txes)))
(println "done"))
(defn audit-transact [txes id]
(dc/transact conn {:tx-data (conj txes {:db/id "datomic.tx"

View File

@@ -3,6 +3,7 @@
[amazonica.aws.s3 :as s3]
[auto-ap.datomic :refer [audit-transact conn]]
[auto-ap.datomic.clients :as d-clients]
[iol-ion.tx :refer [upsert-entity]]
[auto-ap.graphql.utils
:refer [->graphql
assert-admin
@@ -21,7 +22,8 @@
[unilog.context :as lc]
[mount.core :as mount]
[yang.scheduler :as scheduler]
[iol-ion.tx :refer [random-tempid]])
[iol-ion.tx :refer [random-tempid]]
[com.brunobonacci.mulog :as mu])
(:import
(java.util UUID)
(org.apache.commons.codec.binary Base64)))
@@ -99,7 +101,7 @@
:email-contact/description (:description e)})
(:emails edit_client))
:client/feature-flags (:feature_flags edit_client)
:client/feature-flags (:feature_flags edit_client)
:client/ezcater-locations (map
(fn [el]
{:db/id (or (:id el) (random-tempid))
@@ -112,14 +114,15 @@
(map (fn [lm] {:db/id (or (:id lm ) (random-tempid))
:location-match/location (:location lm)
:location-match/matches [(:match lm)]})))
:client/address {:db/id (or (:id (:address edit_client)) (random-tempid))
:address/street1 (:street1 (:address edit_client))
:address/street2 (:street2 (:address edit_client))
:address/city (:city (:address edit_client))
:address/state (:state (:address edit_client))
:address/zip (:zip (:address edit_client))}
:client/address (when (seq (filter identity (vals (:address edit_client))))
{:db/id (or (:id (:address edit_client)) (random-tempid))
:address/street1 (:street1 (:address edit_client))
:address/street2 (:street2 (:address edit_client))
:address/city (:city (:address edit_client))
:address/state (:state (:address edit_client))
:address/zip (:zip (:address edit_client))})
:client/bank-accounts (map (fn [ba]
{:db/id (:id ba)
{:db/id (or (:id ba) (random-tempid))
:bank-account/code (:code ba)
:bank-account/bank-name (:bank_name ba)
:bank-account/bank-code (:bank_code ba)
@@ -145,6 +148,7 @@
(:bank_accounts edit_client))
}
_ (mu/log ::upserting :up updated-entity)
_ (assert-no-shared-transaction-sources client-code [`(upsert-entity ~updated-entity)])
_ (log/info "upserting client" updated-entity)

View File

@@ -588,6 +588,7 @@
account
location]
(take 3 (:journal-entry-line/client+account+location+date result)))))
(take 5)
(drop-while (fn [{[_ _ _ date] :journal-entry-line/client+account+location+date}]
(>= (compare date starting-at) 0)))
first
@@ -595,31 +596,33 @@
0.0)))
(defn get-dirty-entries [{:keys [client account location starting-at]} db ]
(mu/trace ::get-dirty-entries
[]
(let [client (pull-id db client)
account (pull-id db account)]
(into []
(comp
(mapcat (fn [i]
(dc/index-pull db
{:index :avet
:selector [:db/id :journal-entry-line/debit :journal-entry-line/credit :journal-entry-line/client+account+location+date]
:start [:journal-entry-line/client+account+location+date
[client account location starting-at]]
:offset (* i 1000)
:limit 1000}
))
)
(take-while (fn [{[result-client result-account result-location] :journal-entry-line/client+account+location+date}]
(and
(= client result-client)
(= account result-account)
(= location result-location))))
(map (fn [result]
[(:db/id result) (:journal-entry-line/debit result 0.0) (:journal-entry-line/credit result 0.0) ])))
(range)))))
(let [client (pull-id db client)
account (pull-id db account)]
(into []
(comp
(map (fn [i]
(dc/index-pull db
{:index :avet
:selector [:db/id :journal-entry-line/debit :journal-entry-line/credit :journal-entry-line/client+account+location+date]
:start [:journal-entry-line/client+account+location+date
[client account location starting-at]]
:offset (* i 1000)
:limit 1000}
)))
(take-while identity)
(mapcat identity)
(take-while (fn [{[result-client result-account result-location] :journal-entry-line/client+account+location+date}]
#_(println
[[ client result-client]
[ account result-account]
[ location result-location]])
(and
(= client result-client)
(= account result-account)
(= location result-location))))
(map (fn [result]
[(:db/id result) (:journal-entry-line/debit result 0.0) (:journal-entry-line/credit result 0.0) ])))
(range 100))))
(defn compute-running-balance [account-needing-refresh]
(mu/trace ::compute