🎉 Add helpers for take file snapshots

This commit is contained in:
Andrey Antukh 2023-08-03 16:45:01 +02:00
parent f039b904f2
commit d1128a6b1e
3 changed files with 169 additions and 8 deletions

View file

@ -6,6 +6,7 @@
(ns app.srepl.helpers
"A main namespace for server repl."
(:refer-clojure :exclude [parse-uuid])
#_:clj-kondo/ignore
(:require
[app.auth :refer [derive-password]]
@ -39,6 +40,26 @@
(def ^:dynamic *conn*)
(def ^:dynamic *pool*)
(defn println!
[& params]
(locking println
(apply println params)))
(defn parse-uuid
[v]
(if (uuid? v)
v
(d/parse-uuid v)))
(defn resolve-connectable
[o]
(if (db/connection? o)
o
(if (db/pool? o)
o
(or (::db/conn o)
(::db/pool o)))))
(defn reset-password!
"Reset a password to a specific one for a concrete user or all users
if email is `:all` keyword."
@ -104,7 +125,7 @@
(dissoc file :data))))))
(def ^:private sql:retrieve-files-chunk
"SELECT id, name, created_at, data FROM file
"SELECT id, name, created_at, revn, data FROM file
WHERE created_at < ? AND deleted_at is NULL
ORDER BY created_at desc LIMIT ?")
@ -150,11 +171,6 @@
(when (fn? on-end) (on-end))))
(defn- println!
[& params]
(locking println
(apply println params)))
(defn process-files!
"Apply a function to all files in the database, reading them in
batches."