mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 12:28:54 -05:00
✨ Add progress reporting on process-files! srepl helper
This commit is contained in:
parent
f97931647c
commit
893a8992c3
1 changed files with 16 additions and 11 deletions
|
@ -275,9 +275,9 @@
|
||||||
sjobs (ps/create :permits max-jobs)
|
sjobs (ps/create :permits max-jobs)
|
||||||
|
|
||||||
process-file
|
process-file
|
||||||
(fn [file-id tpoint]
|
(fn [file-id idx tpoint]
|
||||||
(try
|
(try
|
||||||
(l/trc :hint "process:file:start" :file-id (str file-id))
|
(l/trc :hint "process:file:start" :file-id (str file-id) :index idx)
|
||||||
(db/tx-run! (assoc main/system ::db/rollback rollback?)
|
(db/tx-run! (assoc main/system ::db/rollback rollback?)
|
||||||
(fn [{:keys [::db/conn] :as system}]
|
(fn [{:keys [::db/conn] :as system}]
|
||||||
(let [file' (get-file* system file-id)
|
(let [file' (get-file* system file-id)
|
||||||
|
@ -311,12 +311,14 @@
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(l/wrn :hint "unexpected error on processing file (skiping)"
|
(l/wrn :hint "unexpected error on processing file (skiping)"
|
||||||
:file-id (str file-id)
|
:file-id (str file-id)
|
||||||
|
:index idx
|
||||||
:cause cause))
|
:cause cause))
|
||||||
(finally
|
(finally
|
||||||
(ps/release! sjobs)
|
(ps/release! sjobs)
|
||||||
(let [elapsed (dt/format-duration (tpoint))]
|
(let [elapsed (dt/format-duration (tpoint))]
|
||||||
(l/trc :hint "process:file:end"
|
(l/trc :hint "process:file:end"
|
||||||
:file-id (str file-id)
|
:file-id (str file-id)
|
||||||
|
:index idx
|
||||||
:elapsed elapsed)))))]
|
:elapsed elapsed)))))]
|
||||||
|
|
||||||
(try
|
(try
|
||||||
|
@ -325,15 +327,18 @@
|
||||||
(db/exec! conn ["SET statement_timeout = 0"])
|
(db/exec! conn ["SET statement_timeout = 0"])
|
||||||
(db/exec! conn ["SET idle_in_transaction_session_timeout = 0"])
|
(db/exec! conn ["SET idle_in_transaction_session_timeout = 0"])
|
||||||
|
|
||||||
(run! (fn [file-id]
|
(try
|
||||||
|
(reduce (fn [idx file-id]
|
||||||
(ps/acquire! sjobs)
|
(ps/acquire! sjobs)
|
||||||
(px/run! executor (partial process-file file-id (dt/tpoint))))
|
(px/run! executor (partial process-file file-id idx (dt/tpoint)))
|
||||||
|
(inc idx))
|
||||||
|
1
|
||||||
(->> (db/cursor conn [sql:get-file-ids (or start-at (dt/now))])
|
(->> (db/cursor conn [sql:get-file-ids (or start-at (dt/now))])
|
||||||
(take max-items)
|
(take max-items)
|
||||||
(map :id)))
|
(map :id)))
|
||||||
|
(finally
|
||||||
;; Close and await tasks
|
;; Close and await tasks
|
||||||
(pu/close! executor)))
|
(pu/close! executor)))))
|
||||||
|
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(l/dbg :hint "process:error" :cause cause))
|
(l/dbg :hint "process:error" :cause cause))
|
||||||
|
|
Loading…
Add table
Reference in a new issue