46 lines
1.3 KiB
Clojure
46 lines
1.3 KiB
Clojure
(ns auto-ap.datomic.migrate.add-client-codes
|
|
(:require
|
|
[datomic.api :as d]))
|
|
|
|
(def name->code
|
|
(->>
|
|
[["Moscini Pizza Inc" "MPI"]
|
|
["Frost Cupcake Factory" "FCF"]
|
|
["Sorelle Italian Bistro" "SIB"]
|
|
["Brian & Erin Skarbek" "BES"]
|
|
["Shared CBC-IBC Expenses" "IBCBC"]
|
|
["Integreat" "INT"]
|
|
["Mama Mia's" "MAM"]
|
|
["Mio Saratoga" "MVSG"]
|
|
["Be Steak A" "BSA"]
|
|
["Jason Skarbek" "JS"]
|
|
["Lefty's East Coast Pizzeria" "LFT"]
|
|
["Orale's" "ORA"]
|
|
["Brown Chicken Brown Cow" "BCBC"]
|
|
["Hiro Mura" "HM"]
|
|
["Mama Lu's Foods" "MLF"]
|
|
["Bella Saratoga" "BSG"]
|
|
["Willow Glen Creamery" "WGC"]
|
|
["Skarbek Law Offices" "SLO"]
|
|
["Mio Vicino - Santa Clara" "MV"]
|
|
["Campbell Brewing Co" "CBC"]
|
|
["Warm Elements" "WE"]
|
|
["Savory Kitchen" "SK"]
|
|
["Demo account" "DEMO"]
|
|
["Roberto's Cantina Inc" "RCI"]
|
|
["Fratello" "FRA"]
|
|
["Whirlygig" "WHG"]
|
|
["Iguanas Burritozilla" "IBC"]]
|
|
(into {}))
|
|
)
|
|
(defn add-client-codes [a]
|
|
[(->> (d/query {:query {:find '[?name ?e]
|
|
:in ['$]
|
|
:where ['[?e :client/name ?name]]}
|
|
:args [(d/db a)]})
|
|
(reduce (fn [result [name id]]
|
|
(if (name->code name)
|
|
(conj result [:db/add id :client/code (name->code name)])
|
|
result))
|
|
[]))])
|