fixes more background jobs.

This commit is contained in:
Bryce
2023-05-23 21:10:52 -07:00
parent 9366347245
commit 8eb7d207e0
2 changed files with 24 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
(ns auto-ap.import.plaid
(:require
[auto-ap.datomic :refer [conn]]
[auto-ap.datomic :refer [conn random-tempid]]
[auto-ap.import.common :refer [wrap-integration]]
[auto-ap.import.transactions :as t]
[auto-ap.plaid.core :as p]
@@ -27,6 +27,7 @@
(defn plaid->transaction [t]
#:transaction {:description-original (:name t)
:raw-id (:transaction_id t)
:db/id (random-tempid)
:id #_{:clj-kondo/ignore [:unresolved-var]}
(di/sha-256 (:transaction_id t))
:amount (if (= "credit" (:type (:account t)))

View File

@@ -6,26 +6,28 @@
[datomic.api :as dc]))
(defn refresh-vendor-usages []
@(dc/transact conn (->> (dc/q '[:find ?v ?c (count ?e)
:in $
:where
[?v :vendor/name]
(or-join [?v ?c ?e]
(and
[?e :invoice/vendor ?v]
[?e :invoice/client ?c])
(and
[?e :transaction/vendor ?v]
[?e :transaction/client ?c])
(and
[?e :journal-entry/vendor ?v]
[?e :journal-entry/client ?c]))]
(dc/db conn))
(map (fn [[v c cnt]]
#:vendor-usage {:vendor v
:client c
:key (str v "-" c)
:count cnt})))))
@(dc/transact-async
conn
(->> (dc/q '[:find ?v ?c (count ?e)
:in $
:where
[?v :vendor/name]
(or-join [?v ?c ?e]
(and
[?e :invoice/vendor ?v]
[?e :invoice/client ?c])
(and
[?e :transaction/vendor ?v]
[?e :transaction/client ?c])
(and
[?e :journal-entry/vendor ?v]
[?e :journal-entry/client ?c]))]
(dc/db conn))
(map (fn [[v c cnt]]
#:vendor-usage {:vendor v
:client c
:key (str v "-" c)
:count cnt})))))
(defn -main [& _]
(execute "vendor-usages" refresh-vendor-usages))