mirror of
https://github.com/penpot/penpot.git
synced 2025-06-02 11:21:39 +02:00
✨ Fix all linter issues on backend code.
This commit is contained in:
parent
6dafc087e9
commit
b80295a21c
48 changed files with 134 additions and 256 deletions
|
@ -11,11 +11,11 @@
|
|||
"Generic task for permanent deletion of objects."
|
||||
(:require
|
||||
[app.common.spec :as us]
|
||||
[integrant.core :as ig]
|
||||
[app.db :as db]
|
||||
[app.metrics :as mtx]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.tools.logging :as log]))
|
||||
[clojure.tools.logging :as log]
|
||||
[integrant.core :as ig]))
|
||||
|
||||
(declare handler)
|
||||
(declare handle-deletion)
|
||||
|
|
|
@ -13,11 +13,8 @@
|
|||
after some period of inactivity (the default threshold is 72h)."
|
||||
(:require
|
||||
[app.common.pages.migrations :as pmg]
|
||||
[app.common.spec :as us]
|
||||
[app.db :as db]
|
||||
[app.metrics :as mtx]
|
||||
[app.storage :as sto]
|
||||
[app.tasks :as tasks]
|
||||
[app.util.blob :as blob]
|
||||
[app.util.time :as dt]
|
||||
[clojure.spec.alpha :as s]
|
||||
|
@ -25,8 +22,8 @@
|
|||
[integrant.core :as ig]))
|
||||
|
||||
(declare handler)
|
||||
(declare retrieve-candidates)
|
||||
(declare process-file)
|
||||
(declare retrieve-candidates)
|
||||
|
||||
(s/def ::storage some?)
|
||||
|
||||
|
@ -52,11 +49,6 @@
|
|||
(run! (partial process-file cfg) files)
|
||||
(recur)))))))
|
||||
|
||||
(defn- decode-row
|
||||
[{:keys [data] :as row}]
|
||||
(cond-> row
|
||||
(bytes? data) (assoc :data (blob/decode data))))
|
||||
|
||||
(def ^:private
|
||||
sql:retrieve-candidates-chunk
|
||||
"select f.id,
|
||||
|
@ -94,14 +86,14 @@
|
|||
(into (keys (:media data)))))
|
||||
|
||||
(defn- process-file
|
||||
[{:keys [conn storage] :as cfg} {:keys [id data age] :as file}]
|
||||
(let [data (-> (blob/decode data)
|
||||
(assoc :id id)
|
||||
(pmg/migrate-data))
|
||||
[{:keys [conn] :as cfg} {:keys [id data age] :as file}]
|
||||
(let [data (-> (blob/decode data)
|
||||
(assoc :id id)
|
||||
(pmg/migrate-data))
|
||||
|
||||
used (collect-used-media data)
|
||||
unused (->> (db/query conn :file-media-object {:file-id id})
|
||||
(remove #(contains? used (:id %))))]
|
||||
used (collect-used-media data)
|
||||
unused (->> (db/query conn :file-media-object {:file-id id})
|
||||
(remove #(contains? used (:id %))))]
|
||||
|
||||
(log/infof "processing file: id='%s' age='%s' to-delete=%s" id age (count unused))
|
||||
|
||||
|
@ -114,9 +106,7 @@
|
|||
(log/debugf "deleting media object: id='%s' media-id='%s' thumb-id='%s'"
|
||||
(:id mobj) (:media-id mobj) (:thumbnail-id mobj))
|
||||
;; NOTE: deleting the file-media-object in the database
|
||||
;; automatically marks to be deleted the associated storage
|
||||
;; objects with the specialized trigger attached
|
||||
;; to :file-media-object table.
|
||||
;; automatically marks as toched the referenced storage objects.
|
||||
(db/delete! conn :file-media-object {:id (:id mobj)}))
|
||||
|
||||
nil))
|
||||
|
|
|
@ -11,17 +11,17 @@
|
|||
"A maintenance task that performs a garbage collection of the file
|
||||
change (transaction) log."
|
||||
(:require
|
||||
[app.common.spec :as us]
|
||||
[integrant.core :as ig]
|
||||
[app.db :as db]
|
||||
[app.metrics :as mtx]
|
||||
[app.util.time :as dt]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.tools.logging :as log]))
|
||||
[clojure.tools.logging :as log]
|
||||
[integrant.core :as ig]))
|
||||
|
||||
(declare handler)
|
||||
|
||||
(s/def ::max-age ::dt/duration)
|
||||
|
||||
(defmethod ig/pre-init-spec ::handler [_]
|
||||
(s/keys :req-un [::db/pool ::mtx/metrics ::max-age]))
|
||||
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
|
||||
(ns app.tasks.sendmail
|
||||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.config :as cfg]
|
||||
[app.metrics :as mtx]
|
||||
[app.util.emails :as emails]
|
||||
[clojure.tools.logging :as log]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.tools.logging :as log]
|
||||
[integrant.core :as ig]))
|
||||
|
||||
(declare handler)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
"A maintenance task that performs a cleanup of already executed tasks
|
||||
from the database table."
|
||||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.db :as db]
|
||||
[app.metrics :as mtx]
|
||||
[app.util.time :as dt]
|
||||
|
|
|
@ -12,15 +12,13 @@
|
|||
information about the current instance and send it to the telemetry
|
||||
server."
|
||||
(:require
|
||||
[app.config :as cfg]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cfg]
|
||||
[app.db :as db]
|
||||
[app.util.http :as http]
|
||||
[app.util.json :as json]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.tools.logging :as log]
|
||||
[integrant.core :as ig]))
|
||||
|
||||
(declare handler)
|
||||
|
@ -60,16 +58,16 @@
|
|||
[{:keys [sprops] :as cfg}]
|
||||
(let [instance-id (:instance-id sprops)
|
||||
data (retrieve-stats cfg)
|
||||
data (assoc data :instance-id instance-id)]
|
||||
(let [response (http/send! {:method :post
|
||||
:uri (:uri cfg)
|
||||
:headers {"content-type" "application/json"}
|
||||
:body (json/encode-str data)})]
|
||||
(when (not= 200 (:status response))
|
||||
(ex/raise :type :internal
|
||||
:code :invalid-response-from-google
|
||||
:context {:status (:status response)
|
||||
:body (:body response)})))))
|
||||
data (assoc data :instance-id instance-id)
|
||||
response (http/send! {:method :post
|
||||
:uri (:uri cfg)
|
||||
:headers {"content-type" "application/json"}
|
||||
:body (json/encode-str data)})]
|
||||
(when (not= 200 (:status response))
|
||||
(ex/raise :type :internal
|
||||
:code :invalid-response-from-google
|
||||
:context {:status (:status response)
|
||||
:body (:body response)}))))
|
||||
|
||||
(defn retrieve-num-teams
|
||||
[conn]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue