Able to find nearby transactions
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
(:require [datomic.api :as dc]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.data.csv :as csv]
|
||||
[auto-ap.datomic :refer [conn]]))
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.datomic :refer [visible-clients]]))
|
||||
|
||||
(println "hi")
|
||||
|
||||
@@ -18,6 +19,46 @@
|
||||
|
||||
|
||||
|
||||
(defn write-recent-transactions-to-embed []
|
||||
(let [visible-clients (visible-clients identity)]
|
||||
(->>
|
||||
(dc/qseq {:query '[:find ?t ?c ?bn ?bt2 ?do ?d ?amt ?v
|
||||
:in $ ?starting [?c ...] pull-expr
|
||||
:where
|
||||
|
||||
[?t :transaction/client ?c]
|
||||
;; [?t :transaction/approval-status :transaction-approval-status/unapproved]
|
||||
;; [?t :transaction/vendor] ;; should be not
|
||||
[(>= ?d ?starting)]
|
||||
[?t :transaction/description-original ?do]
|
||||
[?t :transaction/amount ?amt]
|
||||
[?t :transaction/date ?d]
|
||||
[?t :transaction/bank-account ?b]
|
||||
[?b :bank-account/name ?bn]
|
||||
|
||||
[?b :bank-account/name ?bn]
|
||||
[?b :bank-account/type ?bat]
|
||||
[?bat :db/ident ?bt]
|
||||
[(name ?bt) ?bt2]
|
||||
]
|
||||
:args [(dc/db conn)
|
||||
#inst "2021-01-01"
|
||||
visible-clients
|
||||
pull-expr]})
|
||||
(map first)
|
||||
(sort-by :transaction/date)
|
||||
(reverse)
|
||||
(drop-while (fn [x]
|
||||
(if after
|
||||
(not= (Long/parseLong after) (:db/id x))
|
||||
false)))
|
||||
(#(if after
|
||||
(drop 1 %)
|
||||
%))
|
||||
(take 200)
|
||||
(into [])))
|
||||
)
|
||||
|
||||
(defn write-vendor-training-data []
|
||||
(with-open [f (io/writer "/mnt/data/dev2/ml-test/input/vendor-training.csv")]
|
||||
(csv/write-csv f
|
||||
@@ -73,7 +114,7 @@
|
||||
[?bat :db/ident ?bt]
|
||||
[(name ?bt) ?bt2]]
|
||||
(dc/db auto-ap.datomic/conn)
|
||||
#inst "2022-01-01")
|
||||
#inst "2020-01-01")
|
||||
(map (fn [[t code bn bat d date amt v a]]
|
||||
[t code bn bat d (auto-ap.time/unparse-local (clj-time.coerce/to-date-time date) auto-ap.time/iso-date) amt v a]))))
|
||||
:quote? (constantly true))))
|
||||
|
||||
Reference in New Issue
Block a user