Skip to content

Conversation

@grantfitzsimmons
Copy link
Member

Integrates fixes requested in #7307, reimplemented since it has been too long since the original PR

Fixes #7138

This PR introduces changes that add new tree repair options, including support for rebuilding full names for all nodes in a tree, both excluding and including synonyms. Descriptions of each function have been added under a new "Tree Options" menu. It also adds a nice wrench icon more fitting for the repair tree tool.

newTreeOptions.mp4
treeDemoGitHub.mp4
naturkundemuseum-test-mammals

This has its own permission, so if the user doesn't have the rebuild_full_names for a particular tree, every option will be hidden except for the repair tree option (which has its own permission).

image

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR

Testing instructions

In progress... 🚧

Rebuild Full Names

There is a new option to recompute and update the fullName field for all nodes in a chosen tree definition (Taxon, Geography, Storage, TectonicUnit, GeologicTimePeriod, LithoStrat). It only touches rows whose stored value is missing or differs from the recalculated value.

API endpoint:
/api/specify_tree/{tree}/{treedef_id}/rebuild-full-name

Optional parameter: ?rebuild_synonyms=true (also updates synonym nodes; default is accepted/preferred nodes only as when updating a tree definition)

Examples:
Accepted only: /api/specify_tree/taxon/2/rebuild_fullname
Accepted + synonyms: /api/specify_tree/geography/4/rebuild_fullname?rebuild_synonyms=true

Response (example):

{
  "success": true,
  "rebuild_synonyms": true,
  "changed": { "accepted": 95, "synonyms": 25, "total": 120 }
}

Permissions:
User must have rebuild_fullname on /tree/edit/{tree}. If missing, expect 403.

When to test:

  • After editing rank definition items (separators, direction, before/after text) where synonyms were not automatically updated.
  • After bulk fullName edits via SQL.
  • After tree operations that would otherwise not update synonyms.

Note

You will likely need to edit node fullName values using SQL to test this effectively. In testing, I used an approach like this one on different trees:

select TaxonID, Name, FullName, isAccepted, TaxonTreeDefID from taxon
where TaxonTreeDefID = 17
order by isAccepted asc;

This let me update a mix of both synonyms and accepted names to verify counts are appropriate and that only the specified tree is updated.

UI testing:

  1. Open the Repair Tree menu from User Tools
  2. Click the ⚙️ (options button) next to the tree definition pencil.
  3. Choose both rebuild options
  4. A small status message shows how many names were updated or that none changed.

What to verify:

  • Counts in response look reasonable (non-zero if you deliberately changed inputs).
  • Synonym rebuild only increments synonyms when ?rebuild_synonyms=true (when using the appropriate button).
  • No change to node relationships or ranks.
  • Re-running immediately yields zero changes (no names should need an update).

Difference from existing “Repair Tree” function:
Repair fixes structural numbering; rebuild_fullname only recalculates display names.

@grantfitzsimmons grantfitzsimmons added this to the 7.13.0 milestone Jan 10, 2026
@grantfitzsimmons grantfitzsimmons added the 2 - Trees Issues that are related to the tree system and related functionalities. label Jan 10, 2026
@github-project-automation github-project-automation bot moved this to 📋Back Log in General Tester Board Jan 10, 2026
@grantfitzsimmons grantfitzsimmons removed this from the 7.13.0 milestone Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 - Trees Issues that are related to the tree system and related functionalities.

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Add API endpoint to rebuild fullName fields in a tree

2 participants