From 2331647ec6e0c2a3b561532feb26ce8edd10ef4d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 6 Feb 2024 19:18:22 +0100 Subject: [PATCH] :bug: Add missing team-profile rels cloning on duplicate-team srepl helper --- backend/src/app/srepl/main.clj | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index 599afa646..97f3ab245 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -331,11 +331,18 @@ (defn duplicate-team [team-id & {:keys [name]}] - (let [team-id (if (string? team-id) (parse-uuid team-id) team-id) - name (or name (fn [prev-name] - (str/ffmt "Cloned: % (%)" prev-name (dt/format-instant (dt/now)))))] + (let [team-id (if (string? team-id) (parse-uuid team-id) team-id)] (db/tx-run! main/system - (fn [cfg] - (db/exec-one! cfg ["SET CONSTRAINTS ALL DEFERRED"]) - (-> (assoc cfg ::bfc/timestamp (dt/now)) - (mgmt/duplicate-team :team-id team-id :name name)))))) + (fn [{:keys [::db/conn] :as cfg}] + (db/exec-one! conn ["SET CONSTRAINTS ALL DEFERRED"]) + (let [team (-> (assoc cfg ::bfc/timestamp (dt/now)) + (mgmt/duplicate-team :team-id team-id :name name)) + rels (db/query conn :team-profile-rel {:team-id team-id})] + + (doseq [rel rels] + (let [params (-> rel + (assoc :id (uuid/next)) + (assoc :team-id (:id team)))] + (db/insert! conn :team-profile-rel params + {::db/return-keys false})))))))) +