Skip to content

Commit

Permalink
Fix possible bug in add-xid-whitelist logic (#1785)
Browse files Browse the repository at this point in the history
* Fix possible bug in add-xid-whitelist logic

* use `partial` syntax

* use (when...) to ensure upsert only runs when there is data

* gitignore some generated clojure dev concerns
  • Loading branch information
ballPointPenguin committed Apr 17, 2024
1 parent 5c9743a commit 85ce00f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .gitignore
@@ -1,4 +1,8 @@
.clj-kondo/
.env
prod.env
.envrc
.lsp/
.vscode/settings.json
build/
prod.env
xids.csv
11 changes: 5 additions & 6 deletions bin/add-xid-whitelist.clj
Expand Up @@ -8,8 +8,8 @@

(defn xid-seq [filename]
(map
(fn [line] (first (str/split line #",")))
(line-seq (io/reader filename))))
(fn [line] (first (str/split line #",")))
(line-seq (io/reader filename))))

(defn xid-record [owner xid]
{:owner owner
Expand All @@ -25,17 +25,16 @@
owner-id (resolve-owner-id opts-map)]
(loop [xids-batch (take batch-size xids)
xids-rest (drop batch-size xids)]
(when (seq xids-rest)
(when (seq xids-batch)
(db/upsert! :xid_whitelist
:xid_whitelist_owner_xid_key
(map (partial xid-record owner-id)
xids-batch))
xids-batch)))
(when (seq xids-rest)
(recur (take batch-size xids-rest)
(drop batch-size xids-rest))))
(println "Done")))


(when (= *file* (System/getProperty "babashka.file"))
(apply -main *command-line-args*))


0 comments on commit 85ce00f

Please sign in to comment.