This commit is contained in:
2022-06-24 21:08:33 -07:00
parent ecb12b712c
commit a26469ce2b

View File

@@ -458,17 +458,24 @@
{:client/square-locations [:db/id :square-location/name :square-location/square-id :square-location/client-location]}]) {:client/square-locations [:db/id :square-location/name :square-location/square-id :square-location/client-location]}])
(defn get-square-clients (defn get-square-clients
([] (get-square-clients nil)) ([]
([code]
(d/q '[:find [(pull ?c [:db/id (d/q '[:find [(pull ?c [:db/id
:client/code :client/code
:client/square-auth-token :client/square-auth-token
{:client/square-locations [:db/id :square-location/name :square-location/square-id :square-location/client-location]}]) ...] {:client/square-locations [:db/id :square-location/name :square-location/square-id :square-location/client-location]}]) ...]
:in $ ?code :in $
:where [?c :client/square-auth-token]]
(d/db conn)))
([ & codes]
(d/q '[:find [(pull ?c [:db/id
:client/code
:client/square-auth-token
{:client/square-locations [:db/id :square-location/name :square-location/square-id :square-location/client-location]}]) ...]
:in $ [?code ...]
:where [?c :client/square-auth-token] :where [?c :client/square-auth-token]
[?c :client/code ?code]] [?c :client/code ?code]]
(d/db conn) (d/db conn)
code))) codes)))
(defn upsert-locations (defn upsert-locations
([] (doseq [client (get-square-clients)] ([] (doseq [client (get-square-clients)]