 
 INSERT INTO tree (group_name, name, config, description_html, accepted_tree, host_name)
 VALUES ('treebuilder',
-        'APC',
+        '${classificationTreeName}',
         '{
-          "distribution_key": "APC Dist.",
-          "comment_key": "APC Comment"
+          "distribution_key": "${classificationTreeName} Dist.",
+          "comment_key": "${classificationTreeName} Comment"
         }' :: JSONB,
         '<p>The Australian Plant Census (APC) is a nationally-accepted taxonomy for the Australian flora. APC covers all '
         ||

where blah.id = name.id;
drop table if exists tmp_path_fam;

-- now set the family to the accepted taxon family for all names and synonyms on APC
-- don't change the name_path because that is the name_name_path
UPDATE name name
SET family_id = find_family_name_id(tvte.element_link)
FROM
  tree_element element
  JOIN tree_version_element tvte ON element.id = tvte.tree_element_id
  JOIN tree ON tvte.tree_version_id = tree.current_tree_version_id AND tree.name = 'APC'
  ,
  Instance i,
  Instance s,

    jsonb_agg(DISTINCT (node_id)),
    jsonb_agg(v.id),
    jsonb_object_agg(text(v.id), node_id)
  FROM daily_top_nodes('${classificationTreeName}', '2016-01-01') AS dtn,
    tree_version v,
        tree_element_data_from_start_node(dtn.latest_node_id) AS el_data
  WHERE v.published_at = (dtn.year || '-' || dtn.month || '-' || dtn.day) :: TIMESTAMP
