From 0b29aaecc4e77ce0f89dd926b54fb62c4ae56154 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 5 Jan 2024 13:42:00 +0100 Subject: [PATCH] :lipstick: Format backend code --- backend/src/app/loggers/audit.clj | 6 ++-- backend/src/app/rpc/commands/binfile.clj | 18 +++++------ backend/src/app/rpc/commands/management.clj | 2 +- backend/src/app/srepl/components_v2.clj | 30 +++++++++---------- backend/src/app/storage/gc_deleted.clj | 12 ++++---- backend/test/backend_tests/helpers.clj | 2 +- backend/test/backend_tests/rpc_file_test.clj | 6 ++-- .../rpc_file_thumbnails_test.clj | 4 +-- backend/test/backend_tests/rpc_font_test.clj | 10 ++----- .../test/backend_tests/rpc_profile_test.clj | 4 +-- backend/test/backend_tests/rpc_team_test.clj | 3 +- 11 files changed, 43 insertions(+), 54 deletions(-) diff --git a/backend/src/app/loggers/audit.clj b/backend/src/app/loggers/audit.clj index 3fbd09bdd..3626971fc 100644 --- a/backend/src/app/loggers/audit.clj +++ b/backend/src/app/loggers/audit.clj @@ -201,9 +201,9 @@ ;; because of the timestamp precission (two concurrent requests), in ;; this case we just retry the operation. (let [cfg (-> cfg - (assoc ::rtry/when rtry/conflict-exception?) - (assoc ::rtry/max-retries 6) - (assoc ::rtry/label "persist-audit-log")) + (assoc ::rtry/when rtry/conflict-exception?) + (assoc ::rtry/max-retries 6) + (assoc ::rtry/label "persist-audit-log")) params (-> params (update :props db/tjson) (update :context db/tjson) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index c173ec3bb..81bb6e10a 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -816,16 +816,16 @@ (update :features #(db/create-array conn "text" %)) (update :data blob/encode))] - (l/dbg :hint "create file" :id (str file-id') ::l/sync? true) + (l/dbg :hint "create file" :id (str file-id') ::l/sync? true) - (if overwrite? - (create-or-update-file! conn file) - (db/insert! conn :file file)) + (if overwrite? + (create-or-update-file! conn file) + (db/insert! conn :file file)) - (when overwrite? - (db/delete! conn :file-thumbnail {:file-id file-id'})) + (when overwrite? + (db/delete! conn :file-thumbnail {:file-id file-id'})) - file-id')))) + file-id')))) (defmethod read-section :v1/rels [{:keys [::db/conn ::input ::timestamp]}] @@ -1008,8 +1008,8 @@ (if (:image v) (update-in res [k :image :id] lookup-index) res)) - colors - colors)) + colors + colors)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; HIGH LEVEL API diff --git a/backend/src/app/rpc/commands/management.clj b/backend/src/app/rpc/commands/management.clj index aaf51c3a0..416056a91 100644 --- a/backend/src/app/rpc/commands/management.clj +++ b/backend/src/app/rpc/commands/management.clj @@ -312,7 +312,7 @@ (teams/check-read-permissions! conn profile-id team-id)) (let [projs (db/query conn :project - {:team-id team-id}) + {:team-id team-id}) files (let [sql (str "SELECT f.id " " FROM file AS f " diff --git a/backend/src/app/srepl/components_v2.clj b/backend/src/app/srepl/components_v2.clj index 049fc3574..fec852f08 100644 --- a/backend/src/app/srepl/components_v2.clj +++ b/backend/src/app/srepl/components_v2.clj @@ -157,7 +157,7 @@ :or {rollback? true skip-on-error true validate? false - max-procs 1 } + max-procs 1} :as opts}] (l/dbg :hint "migrate:start" :rollback rollback?) @@ -256,20 +256,20 @@ :else (px/submit! scope (fn [] - (try - (mark-team-migration! system id) - (-> (assoc system ::db/rollback rollback?) - (feat/migrate-team! id - :max-procs max-procs - :validate? validate? - :throw-on-validate? (not skip-on-error))) - (catch Throwable cause - (l/err :hint "unexpected error on processing team" - :team-id (str id) - :cause cause)) - (finally - (ps/release! sjobs) - (unmark-team-migration! system id))))))))] + (try + (mark-team-migration! system id) + (-> (assoc system ::db/rollback rollback?) + (feat/migrate-team! id + :max-procs max-procs + :validate? validate? + :throw-on-validate? (not skip-on-error))) + (catch Throwable cause + (l/err :hint "unexpected error on processing team" + :team-id (str id) + :cause cause)) + (finally + (ps/release! sjobs) + (unmark-team-migration! system id))))))))] (l/dbg :hint "migrate:start" :rollback rollback? diff --git a/backend/src/app/storage/gc_deleted.clj b/backend/src/app/storage/gc_deleted.clj index 2852c8fe6..8d1d0e5ad 100644 --- a/backend/src/app/storage/gc_deleted.clj +++ b/backend/src/app/storage/gc_deleted.clj @@ -113,13 +113,13 @@ (fn [params] (let [min-age (dt/duration (or (:min-age params) min-age))] (db/tx-run! cfg (fn [cfg] - (let [cfg (assoc cfg ::min-age min-age) - total (clean-deleted! cfg)] + (let [cfg (assoc cfg ::min-age min-age) + total (clean-deleted! cfg)] - (l/inf :hint "task finished" - :min-age (dt/format-duration min-age) - :total total) + (l/inf :hint "task finished" + :min-age (dt/format-duration min-age) + :total total) - {:deleted total})))))) + {:deleted total})))))) diff --git a/backend/test/backend_tests/helpers.clj b/backend/test/backend_tests/helpers.clj index 646905c51..8073c40a7 100644 --- a/backend/test/backend_tests/helpers.clj +++ b/backend/test/backend_tests/helpers.clj @@ -20,8 +20,8 @@ [app.config :as cf] [app.db :as db] [app.main :as main] - [app.media :as-alias mtx] [app.media] + [app.media :as-alias mtx] [app.migrations] [app.msgbus :as-alias mbus] [app.rpc :as-alias rpc] diff --git a/backend/test/backend_tests/rpc_file_test.clj b/backend/test/backend_tests/rpc_file_test.clj index cbce720c5..6be373a29 100644 --- a/backend/test/backend_tests/rpc_file_test.clj +++ b/backend/test/backend_tests/rpc_file_test.clj @@ -233,8 +233,7 @@ (t/is (= 1 (:processed res)))) (let [rows (th/db-query :file-data-fragment {:file-id (:id file)})] - (t/is (= 2 (count rows)))) - ))) + (t/is (= 2 (count rows))))))) @@ -904,8 +903,7 @@ (let [error (:error out) error-data (ex-data error)] (t/is (th/ex-info? error)) - (t/is (= (:type error-data) :not-found)))) - )) + (t/is (= (:type error-data) :not-found)))))) (t/deftest object-thumbnails-ops diff --git a/backend/test/backend_tests/rpc_file_thumbnails_test.clj b/backend/test/backend_tests/rpc_file_thumbnails_test.clj index 12e5d7158..88e2ac2d2 100644 --- a/backend/test/backend_tests/rpc_file_thumbnails_test.clj +++ b/backend/test/backend_tests/rpc_file_thumbnails_test.clj @@ -248,9 +248,7 @@ (let [result (th/run-task! :storage-gc-deleted {:min-age 0})] (t/is (= 1 (:deleted result)))) - (t/is (some? (sto/get-object storage (:media-id row2)))) - - ))) + (t/is (some? (sto/get-object storage (:media-id row2))))))) (t/deftest error-on-direct-storage-obj-deletion (let [storage (::sto/storage th/*system*) diff --git a/backend/test/backend_tests/rpc_font_test.clj b/backend/test/backend_tests/rpc_font_test.clj index 5d31f14b1..2d6404435 100644 --- a/backend/test/backend_tests/rpc_font_test.clj +++ b/backend/test/backend_tests/rpc_font_test.clj @@ -153,8 +153,7 @@ (let [res (th/run-task! :storage-gc-touched {:min-age 0})] (t/is (= 0 (:freeze res))) - (t/is (= 6 (:delete res)))) - )) + (t/is (= 6 (:delete res)))))) (t/deftest font-deletion-2 (let [prof (th/create-profile* 1 {:is-active true}) @@ -216,8 +215,7 @@ (let [res (th/run-task! :storage-gc-touched {:min-age 0})] (t/is (= 0 (:freeze res))) - (t/is (= 3 (:delete res)))) - )) + (t/is (= 3 (:delete res)))))) (t/deftest font-deletion-3 (let [prof (th/create-profile* 1 {:is-active true}) @@ -278,6 +276,4 @@ (let [res (th/run-task! :storage-gc-touched {:min-age 0})] (t/is (= 0 (:freeze res))) - (t/is (= 3 (:delete res)))) - - )) + (t/is (= 3 (:delete res)))))) diff --git a/backend/test/backend_tests/rpc_profile_test.clj b/backend/test/backend_tests/rpc_profile_test.clj index f21dc17ec..24776a3cb 100644 --- a/backend/test/backend_tests/rpc_profile_test.clj +++ b/backend/test/backend_tests/rpc_profile_test.clj @@ -166,9 +166,7 @@ out (th/command! params)] ;; (th/print-result! out) (let [result (:result out)] - (t/is (= uuid/zero (:id result))))) - - )) + (t/is (= uuid/zero (:id result))))))) (t/deftest registration-domain-whitelist (let [whitelist #{"gmail.com" "hey.com" "ya.ru"}] diff --git a/backend/test/backend_tests/rpc_team_test.clj b/backend/test/backend_tests/rpc_team_test.clj index 8252e9aa3..60a42a8c5 100644 --- a/backend/test/backend_tests/rpc_team_test.clj +++ b/backend/test/backend_tests/rpc_team_test.clj @@ -462,5 +462,4 @@ (t/is (dt/instant? (:deleted-at (first rows))))) (let [result (th/run-task! :objects-gc {:min-age 0})] - (t/is (= 5 (:processed result)))) - )) + (t/is (= 5 (:processed result))))))