mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 18:18:24 -05:00
✨ Add a task for asynchronous object update operation
This commit is contained in:
parent
caaf695352
commit
e27c0b2086
2 changed files with 38 additions and 1 deletions
|
@ -349,6 +349,8 @@
|
||||||
:audit-log-archive (ig/ref :app.loggers.audit.archive-task/handler)
|
:audit-log-archive (ig/ref :app.loggers.audit.archive-task/handler)
|
||||||
:audit-log-gc (ig/ref :app.loggers.audit.gc-task/handler)
|
:audit-log-gc (ig/ref :app.loggers.audit.gc-task/handler)
|
||||||
|
|
||||||
|
:object-update
|
||||||
|
(ig/ref :app.tasks.object-update/handler)
|
||||||
:process-webhook-event
|
:process-webhook-event
|
||||||
(ig/ref ::webhooks/process-event-handler)
|
(ig/ref ::webhooks/process-event-handler)
|
||||||
:run-webhook
|
:run-webhook
|
||||||
|
@ -376,7 +378,10 @@
|
||||||
::sto/storage (ig/ref ::sto/storage)}
|
::sto/storage (ig/ref ::sto/storage)}
|
||||||
|
|
||||||
:app.tasks.orphan-teams-gc/handler
|
:app.tasks.orphan-teams-gc/handler
|
||||||
{::db/pool (ig/ref ::db/pool)}
|
{::db/pool (ig/ref ::db/pool)}
|
||||||
|
|
||||||
|
:app.tasks.object-update/handler
|
||||||
|
{::db/pool (ig/ref ::db/pool)}
|
||||||
|
|
||||||
:app.tasks.file-gc/handler
|
:app.tasks.file-gc/handler
|
||||||
{::db/pool (ig/ref ::db/pool)
|
{::db/pool (ig/ref ::db/pool)
|
||||||
|
|
32
backend/src/app/tasks/object_update.clj
Normal file
32
backend/src/app/tasks/object_update.clj
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
|
(ns app.tasks.object-update
|
||||||
|
"A task used for perform simple object properties update
|
||||||
|
in an asynchronous flow."
|
||||||
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
|
[app.common.logging :as l]
|
||||||
|
[app.db :as db]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[integrant.core :as ig]))
|
||||||
|
|
||||||
|
(defn- update-object
|
||||||
|
[{:keys [::db/conn] :as cfg} {:keys [id object key val] :as props}]
|
||||||
|
(l/trc :hint "update object prop"
|
||||||
|
:id (str id)
|
||||||
|
:object (d/name object)
|
||||||
|
:key (d/name key)
|
||||||
|
:val val)
|
||||||
|
(db/update! conn object {key val} {:id id} {::db/return-keys false}))
|
||||||
|
|
||||||
|
(defmethod ig/pre-init-spec ::handler [_]
|
||||||
|
(s/keys :req [::db/pool]))
|
||||||
|
|
||||||
|
(defmethod ig/init-key ::handler
|
||||||
|
[_ cfg]
|
||||||
|
(fn [{:keys [props] :as params}]
|
||||||
|
(db/tx-run! cfg update-object props)))
|
Loading…
Add table
Reference in a new issue