From faaad6a8f6439ead8a086441a2b2fe6f99552217 Mon Sep 17 00:00:00 2001 From: RJ Sheperd Date: Wed, 25 Mar 2026 13:15:51 -0700 Subject: [PATCH 1/2] [BHP1-1502] Add Downwind Canopy Fuel / Torching Trees Subgroups --- ...026_03_25_add_torching_trees_subgroups.clj | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 development/migrations/2026_03_25_add_torching_trees_subgroups.clj diff --git a/development/migrations/2026_03_25_add_torching_trees_subgroups.clj b/development/migrations/2026_03_25_add_torching_trees_subgroups.clj new file mode 100644 index 000000000..35805ed02 --- /dev/null +++ b/development/migrations/2026_03_25_add_torching_trees_subgroups.clj @@ -0,0 +1,171 @@ +(ns migrations.2026-03-25-add-torching-trees-subgroups + (:require [schema-migrate.interface :as sm] + [datomic.api :as d] + [behave-cms.store :refer [default-conn]] + [behave-cms.server :as cms])) + +;; =========================================================================================================== +;; Overview +;; =========================================================================================================== + +;; Add two new subgroups under Crown > Input > Spotting > Torching Trees: +;; 1. Downwind Canopy Fuel — Downwind Canopy Cover, Downwind Canopy Height +;; 2. Torching Trees — Number of Torching Trees, DBH, Species, Height +;; +;; Steps: +;; 1. Create two new intermediate subgroups under torching_trees +;; 2. Move existing child groups into the new subgroups +;; 3. Retract old child references from the parent +;; 4. Add translations only for the two brand-new subgroups + +;; =========================================================================================================== +;; Initialize +;; =========================================================================================================== + +(cms/init-db!) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def conn (default-conn)) + +;; =========================================================================================================== +;; Helpers +;; =========================================================================================================== + +#_{:clj-kondo/ignore [:missing-docstring]} +(def torching-trees-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees")) + +;; Existing child group eids — Downwind Canopy Fuel +#_{:clj-kondo/ignore [:missing-docstring]} +(def downwind-canopy-cover-group-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:downwind-canopy-cover")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def downwind-canopy-height-group-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:downwind-canopy-height")) + +;; Existing child group eids — Torching Trees +#_{:clj-kondo/ignore [:missing-docstring]} +(def number-of-torching-trees-group-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:number_of_torching_trees_numeric_value")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def dbh-group-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:dbh_diameter_at_breast_height")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def torching-tree-species-group-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:torching_tree_species")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def torching-tree-height-group-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:torching_tree_height")) + +;; Existing group-variable eids +#_{:clj-kondo/ignore [:missing-docstring]} +(def downwind-canopy-cover-gv-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:downwind-canopy-cover:downwind-canopy-cover")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def downwind-canopy-height-gv-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:downwind-canopy-height:downwind-canopy-height")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def number-of-torching-trees-gv-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:number_of_torching_trees_numeric_value:number_of_torching_trees_numeric_value")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def dbh-gv-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:dbh_diameter_at_breast_height:dbh_diameter_at_breast_height")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def torching-tree-species-gv-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:torching_tree_species:torching_tree_species")) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def torching-tree-height-gv-eid + (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:torching_tree_height:torching_tree_height")) + +;; Translation key prefix +#_{:clj-kondo/ignore [:missing-docstring]} +(def base ) +#_{:clj-kondo/ignore [:missing-docstring]} +(def result-base "behaveplus:crown:result:spotting:torching_trees") + +;; =========================================================================================================== +;; Payload +;; =========================================================================================================== + +#_{:clj-kondo/ignore [:missing-docstring]} +(def payload + [;; 1. Create new intermediate subgroups + (sm/postwalk-insert + {:db/id -1 + :group/_children torching-trees-eid + :group/name "Downwind Canopy Fuel" + :group/order 0}) + + (sm/postwalk-insert + {:db/id -2 + :group/_children torching-trees-eid + :group/name "Torching Trees" + :group/order 1}) + + ;; 2. Move existing groups as children of Downwind Canopy Fuel and update keys + {:db/id downwind-canopy-cover-group-eid + :group/_children -1 + :group/order 0} + + {:db/id downwind-canopy-height-group-eid + :group/_children -1 + :group/order 1} + + ;; 3. Move existing groups as children of Torching Trees and update keys + {:db/id number-of-torching-trees-group-eid + :group/_children -2 + :group/order 0} + + {:db/id dbh-group-eid + :group/_children -2 + :group/order 1} + + {:db/id torching-tree-species-group-eid + :group/_children -2 + :group/order 2} + + {:db/id torching-tree-height-group-eid + :group/_children -2 + :group/order 3} + + ;; 4. Retract old child references from torching_trees + [:db/retract torching-trees-eid :group/children downwind-canopy-cover-group-eid] + [:db/retract torching-trees-eid :group/children downwind-canopy-height-group-eid] + [:db/retract torching-trees-eid :group/children number-of-torching-trees-group-eid] + [:db/retract torching-trees-eid :group/children dbh-group-eid] + [:db/retract torching-trees-eid :group/children torching-tree-species-group-eid] + [:db/retract torching-trees-eid :group/children torching-tree-height-group-eid]]) + +;; New translations only needed for the two brand-new subgroups +#_{:clj-kondo/ignore [:missing-docstring]} +(def new-translations-payload + (sm/build-translations-payload + conn 100 + {"behaveplus:crown:input:spotting:torching_trees:downwind_canopy_fuel" "Downwind Canopy Fuel" + "behaveplus:crown:input:spotting:torching_trees:torching_trees" "Torching Trees"})) + +;; =========================================================================================================== +;; Transact Payload +;; =========================================================================================================== + +(comment + #_{:clj-kondo/ignore [:missing-docstring]} + (try (def tx-data @(d/transact conn (concat payload + new-translations-payload))) + (catch Exception e (str "caught exception: " (.getMessage e))))) + +;; =========================================================================================================== +;; In case we need to rollback. +;; =========================================================================================================== + +(comment + (sm/rollback-tx! conn tx-data)) From 61a43143cc0d680c32fb1c549ef468e2982793cb Mon Sep 17 00:00:00 2001 From: RJ Sheperd Date: Thu, 26 Mar 2026 14:34:37 -0700 Subject: [PATCH 2/2] Add translation keys --- .../2026_03_25_add_torching_trees_subgroups.clj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/development/migrations/2026_03_25_add_torching_trees_subgroups.clj b/development/migrations/2026_03_25_add_torching_trees_subgroups.clj index 35805ed02..f9bf66425 100644 --- a/development/migrations/2026_03_25_add_torching_trees_subgroups.clj +++ b/development/migrations/2026_03_25_add_torching_trees_subgroups.clj @@ -86,12 +86,6 @@ (def torching-tree-height-gv-eid (sm/t-key->eid conn "behaveplus:crown:input:spotting:torching_trees:torching_tree_height:torching_tree_height")) -;; Translation key prefix -#_{:clj-kondo/ignore [:missing-docstring]} -(def base ) -#_{:clj-kondo/ignore [:missing-docstring]} -(def result-base "behaveplus:crown:result:spotting:torching_trees") - ;; =========================================================================================================== ;; Payload ;; =========================================================================================================== @@ -103,12 +97,18 @@ {:db/id -1 :group/_children torching-trees-eid :group/name "Downwind Canopy Fuel" + :group/translation-key "behaveplus:crown:input:spotting:torching_trees:downwind_canopy_fuel" + :group/result-translation-key "behaveplus:crown:result:spotting:torching_trees:downwind_canopy_fuel" + :group/help-key "behaveplus:crown:input:spotting:torching_trees:downwind_canopy_fuel:help" :group/order 0}) (sm/postwalk-insert {:db/id -2 :group/_children torching-trees-eid :group/name "Torching Trees" + :group/translation-key "behaveplus:crown:input:spotting:torching_trees:torching_trees" + :group/result-translation-key "behaveplus:crown:result:spotting:torching_trees:torching_trees" + :group/help-key "behaveplus:crown:input:spotting:torching_trees:torching_trees:help" :group/order 1}) ;; 2. Move existing groups as children of Downwind Canopy Fuel and update keys