feat(trees): add tree repair utility#7633
Draft
grantfitzsimmons wants to merge 4 commits intomainfrom
Draft
Conversation
Integrates fixes requested in #7307
Triggered by a477de2 on branch refs/heads/issue-7138-v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
This has its own permission, so if the user doesn't have the
rebuild_full_namesfor a particular tree, every option will be hidden except for the repair tree option (which has its own permission).Checklist
self-explanatory (or properly documented)
Testing instructions
In progress... 🚧
Rebuild Full Names
There is a new option to recompute and update the
fullNamefield 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-nameOptional 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_fullnameAccepted + synonyms:
/api/specify_tree/geography/4/rebuild_fullname?rebuild_synonyms=trueResponse (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:
fullNameedits via SQL.Note
You will likely need to edit node
fullNamevalues using SQL to test this effectively. In testing, I used an approach like this one on different trees: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:
What to verify:
?rebuild_synonyms=true(when using the appropriate button).Difference from existing “Repair Tree” function:
Repair fixes structural numbering;
rebuild_fullnameonly recalculates display names.