0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

🎉 Add more helpers on srepl ns

This commit is contained in:
Andrey Antukh 2022-08-11 15:37:58 +02:00
parent b3623ed14c
commit 918d2ab4a9

View file

@ -88,7 +88,7 @@
The `on-file` parameter should be a function that receives the file
and the previous state and returns the new state."
[system {:keys [chunk-size on-file] :or {chunk-size 10}}]
[system & {:keys [chunk-size on-file] :or {chunk-size 10}}]
(letfn [(get-chunk [conn cursor]
(let [rows (db/exec! conn [sql:retrieve-files-chunk cursor chunk-size])]
[(some->> rows peek :created-at) (seq rows)]))
@ -109,6 +109,21 @@
(recur state (rest files)))
state)))))
(defn analyze-file-data
[system & {:keys [id on-form on-data]}]
(let [file (get-file system id)]
(cond
(fn? on-data)
(on-data (:data file))
(fn? on-form)
(walk/postwalk (fn [form]
(on-form form)
form)
(:data file)))
nil))
(defn update-pages
"Apply a function to all pages of one file. The function receives a page and returns an updated page."
[data f]