diff --git a/src/clj/user.clj b/src/clj/user.clj index c1f315e3..28c073aa 100644 --- a/src/clj/user.clj +++ b/src/clj/user.clj @@ -22,7 +22,8 @@ [nrepl.middleware.print] [unilog.context :as lc] [com.brunobonacci.mulog :as mu] - [com.brunobonacci.mulog.buffer :as rb]) + [com.brunobonacci.mulog.buffer :as rb] + [datomic.api :as d]) (:import (org.apache.commons.io.input BOMInputStream))) @@ -328,7 +329,6 @@ #_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn tx-range-detail [i] (map (juxt :e #(pull-attr (dc/db conn) :db/ident (:a %)) :v) - (mapcat :data (dc/tx-range conn {:start (- i 100) :end (+ i 100)})))) @@ -508,7 +508,28 @@ (set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint)) -(defn sample-ledger-import [client-code] - [] - ) - +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} +(defn sample-ledger-import + ([client-code] + (sample-ledger-import client-code 10)) + ([client-code n] + (let [client-location (ffirst (d/q '[:find ?l :in $ ?c :where [?c :client/locations ?l]] (dc/db conn) [:client/code client-code]))] + (clojure.data.csv/write-csv + *out* + (for [n (range n) + :let [v (rand-nth (map first (d/q '[:find ?vn :where [_ :vendor/name ?vn]] (dc/db conn)))) + [{a-1 :account/numeric-code a-1-location :account/location} + {a-2 :account/numeric-code a-2-location :account/location}] (->> (d/q '[:find (pull ?a [:account/numeric-code :account/location]) :where [?a :account/numeric-code]] + (dc/db conn)) + (map first) + (shuffle) + (take 2)) + amount (rand-int 2000) + d (-> (t/now) + (t/minus (t/days (rand-int 60))) + (atime/unparse atime/normal-date)) + id (rand-int 100000)] + a [[(str id) client-code "synthetic" v d a-1 (or a-1-location client-location) 0 amount ] + [(str id) client-code "synthetic" v d a-2 (or a-2-location client-location) amount 0]]] + a) + :separator \tab))))