diff --git a/iol_ion/src/iol_ion/tx/upsert_ledger.clj b/iol_ion/src/iol_ion/tx/upsert_ledger.clj index 411061f1..8c1e65ce 100644 --- a/iol_ion/src/iol_ion/tx/upsert_ledger.clj +++ b/iol_ion/src/iol_ion/tx/upsert_ledger.clj @@ -12,7 +12,6 @@ :start [:journal-entry-line/client+account+location+date (:journal-entry-line/client+account+location+date jel) (:db/id jel)] - :limit 3 }) (filter (fn line-must-match-client-account-location [result] (and diff --git a/src/clj/auto_ap/datomic.clj b/src/clj/auto_ap/datomic.clj index 3ca7e714..cb4a05ba 100644 --- a/src/clj/auto_ap/datomic.clj +++ b/src/clj/auto_ap/datomic.clj @@ -28,7 +28,7 @@ :stop nil) (mount/defstate conn - :start (dc/connect "datomic:ddb://us-east-1/iol-dev/dev") + :start (dc/connect uri) :stop nil) #_(def uri "datomic:mem://datomic-transactor:4334/invoice") diff --git a/src/clj/auto_ap/graphql/clients.clj b/src/clj/auto_ap/graphql/clients.clj index f93729c4..d48cd658 100644 --- a/src/clj/auto_ap/graphql/clients.clj +++ b/src/clj/auto_ap/graphql/clients.clj @@ -188,7 +188,6 @@ {:index :avet :selector [:db/id :journal-entry-line/location :journal-entry-line/account :journal-entry-line/running-balance :journal-entry-line/client+account+location+date {:journal-entry/_line-items [:journal-entry/date :journal-entry/client]}] :start [:journal-entry-line/client+account+location+date [client bank-account "A" #inst "2030-01-01"]] - :limit 1 :reverse true }) (filter (fn [{[c b] :journal-entry-line/client+account+location+date}] diff --git a/src/clj/auto_ap/ledger.clj b/src/clj/auto_ap/ledger.clj index 8470e876..b19ff4a2 100644 --- a/src/clj/auto_ap/ledger.clj +++ b/src/clj/auto_ap/ledger.clj @@ -346,8 +346,7 @@ @(->> (dc/qseq {:query '[:find (pull ?je [:journal-entry/date :journal-entry/client {:journal-entry/line-items [:journal-entry-line/account :journal-entry-line/location :db/id]}]) :in $ ?c :where [?je :journal-entry/client ?c]] - :args [(dc/db conn)]} - client) + :args [(dc/db conn) client]}) (map first) (mapcat (fn [je] (map (fn [jel] @@ -442,8 +441,7 @@ {:index :avet :selector [:db/id :journal-entry-line/running-balance :journal-entry-line/client+account+location+date] :start [:journal-entry-line/client+account+location+date [client account location starting-at]] - :reverse true - :limit 500}) + :reverse true}) (take-while (fn [result] (= [client account @@ -461,17 +459,6 @@ 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}] (and (= client result-client) @@ -479,7 +466,13 @@ (= 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)))) + (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]] + + })))) (defn compute-running-balance [account-needing-refresh] (mu/trace ::compute diff --git a/test/clj/auto_ap/import/transactions_test.clj b/test/clj/auto_ap/import/transactions_test.clj index da15ced8..2e00f39d 100644 --- a/test/clj/auto_ap/import/transactions_test.clj +++ b/test/clj/auto_ap/import/transactions_test.clj @@ -3,7 +3,7 @@ [auto-ap.datomic :refer [conn]] [auto-ap.import.transactions :as sut] [auto-ap.integration.util :refer [wrap-setup]] - [iol-ion.tx :refer [upsert-transaction]] + [iol-ion.tx.upsert-transaction :refer [upsert-transaction]] [datomic.api :as dc] [clj-time.coerce :as coerce] [clojure.test :as t] diff --git a/test/clj/auto_ap/integration/graphql/ledger/running_balance.clj b/test/clj/auto_ap/integration/graphql/ledger/running_balance.clj index 07036586..7811825b 100644 --- a/test/clj/auto_ap/integration/graphql/ledger/running_balance.clj +++ b/test/clj/auto_ap/integration/graphql/ledger/running_balance.clj @@ -2,7 +2,7 @@ (:require [auto-ap.datomic :refer [conn pull-attr]] [auto-ap.ledger :as sut] - [iol-ion.tx :refer [upsert-ledger]] + [iol-ion.tx.upsert-ledger :refer [upsert-ledger]] [auto-ap.integration.util :refer [wrap-setup]] [clojure.test :as t :refer [deftest is testing use-fixtures]] [datomic.api :as d])) diff --git a/test/clj/auto_ap/integration/util.clj b/test/clj/auto_ap/integration/util.clj index a3b658b6..96182e8b 100644 --- a/test/clj/auto_ap/integration/util.clj +++ b/test/clj/auto_ap/integration/util.clj @@ -1,18 +1,16 @@ (ns auto-ap.integration.util (:require [datomic.api :as dc] - [auto-ap.datomic :refer [client conn transact-schema]] + [auto-ap.datomic :refer [conn transact-schema]] [clj-time.core :as time])) (defn wrap-setup [f] - (require 'datomic.dev-local) - (with-redefs [auto-ap.datomic/client (dc/client {:server-type :dev-local - :system "test"})] - (dc/create-database client {:db-name "test"}) - (with-redefs [auto-ap.datomic/conn (dc/connect client {:db-name "test"})] + (with-redefs [auto-ap.datomic/uri "datomic:mem://test"] + (dc/create-database auto-ap.datomic/uri) + (with-redefs [auto-ap.datomic/conn auto-ap.datomic/uri] (transact-schema conn) (f) - (dc/delete-database client {:db-name "test"})))) + (dc/delete-database auto-ap.datomic/uri)))) (defn admin-token [] {:user "TEST ADMIN" diff --git a/test/clj/auto_ap/routes/invoice_test.clj b/test/clj/auto_ap/routes/invoice_test.clj index 400eb529..48389776 100644 --- a/test/clj/auto_ap/routes/invoice_test.clj +++ b/test/clj/auto_ap/routes/invoice_test.clj @@ -61,10 +61,10 @@ :customer-identifier "ABC" :invoice-number "789")]) (t/is (= [["DE"]] (dc/q '[:find ?l - :where [?i :invoice/invoice-number "789"] - [?i :invoice/expense-accounts ?ea] - [?ea :invoice-expense-account/location ?l] - (dc/db conn))))) + :where [?i :invoice/invoice-number "789"] + [?i :invoice/expense-accounts ?ea] + [?ea :invoice-expense-account/location ?l]] + (dc/db conn))))) (t/testing "Should code invoice" (let [{{:strs [my-default-account coded-vendor]} :tempids} (dc/transact conn diff --git a/things-to-search-for.txt b/things-to-search-for.txt index 4788f032..51c080e1 100644 --- a/things-to-search-for.txt +++ b/things-to-search-for.txt @@ -146,3 +146,11 @@ WGC,2021-03-26,Equipment 3,Kitchen Equipment WGC,2021-03-26,Equipment 3,Kitchen Equipment BSG,2021-05-26,Advertising,Design WGC,2021-09-17,Advertising,Promotional or Donation Meal Comps + + + + +differences: +q only supports one query format in on-prem, multiple in cloud +qseq takes a different format too +index-pull is not chunked