From eee28a57931c2fe32ba55271b8ae98ff49b46579 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 15 Dec 2023 14:59:00 +0100 Subject: [PATCH] :sparkles: Simplify feature handling on components-v2 migration functions --- backend/src/app/features/components_v2.clj | 26 ++++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index 19b4f0b9d..99074dd59 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -9,7 +9,6 @@ [app.common.data :as d] [app.common.data.macros :as dm] [app.common.exceptions :as ex] - [app.common.features :as cfeat] [app.common.files.changes :as cp] [app.common.files.changes-builder :as fcb] [app.common.files.helpers :as cfh] @@ -769,12 +768,13 @@ fdata (migrate-graphics fdata)] (update fdata :options assoc :components-v2 true))))) -(defn- prepare-fdata - [fdata id] - (-> fdata - (assoc :id id) - (fdata/process-pointers deref) - (fmg/migrate-data))) +(defn- get-file + [system id] + (binding [pmap/*load-fn* (partial fdata/load-pointer system id)] + (-> (files/get-file system id :migrate? false) + (update :data assoc :id id) + (update :data fdata/process-pointers deref) + (fmg/migrate-file)))) (defn- validate-file! [file libs throw-on-validate?] @@ -788,18 +788,10 @@ (defn- process-file [{:keys [::db/conn] :as system} id & {:keys [validate? throw-on-validate?]}] - (let [file (binding [cfeat/*new* (atom #{}) - pmap/*load-fn* (partial fdata/load-pointer system id)] - (-> (files/get-file system id :migrate? false) - (update :data prepare-fdata id) - (update :features into (deref cfeat/*new*)) - (update :features cfeat/migrate-legacy-features))) + (let [file (get-file system id) libs (->> (files/get-file-libraries conn id) - (into [file] (map (fn [{:keys [id]}] - (binding [pmap/*load-fn* (partial fdata/load-pointer system id)] - (-> (files/get-file system id :migrate? false) - (update :data prepare-fdata id)))))) + (into [file] (comp (map :id) (map (partial get-file system)))) (d/index-by :id)) file (-> file