Improve suffix unit conversion deletion with cascade delete and UI warnings - #1693
Open
BunnyBea83 wants to merge 14 commits into
Open
Improve suffix unit conversion deletion with cascade delete and UI warnings#1693BunnyBea83 wants to merge 14 commits into
BunnyBea83 wants to merge 14 commits into
Conversation
- Add checkUnitDependencies service for validation - Fix async race condition in removeAdditionalConversionsAndUnits - Add bidirectional conversion support and depth limiting - Enhance simulation to account for suffix unit cascades
- Add checkUnitDependencies service for validation - Fix async race condition in removeAdditionalConversionsAndUnits - Add bidirectional conversion support and depth limiting - Enhance simulation to account for suffix unit cascades
- Add getConversionsByUnitId method - Add deleteConversionAndRelatedSuffixes with dependency checks
- Add dependency checks before suffix unit cleanup - Handle bidirectional conversions safely - Add row-level locking for concurrent operations - Improve error messages with meter/group details
- Show affected meters/groups in deletion warnings - Improve suffix unit warning formatting - Add translation keys for dependency warnings
- Removed getConversionsByUnitId method as it is no longer used - Removed deleteConversionAndRelatedSuffixes method as it is no longer used
- Refactored hide suffix functions to delete suffix functions - Suffix checks now account for suffix inputs (type of unit = unit, suffix = <contains a string>) when checking for dependencies.
- Added deleteUnitSafely method - Method checks for dependencies of the unit, clears unit connections to meters, groups, and conversions, then deletes the unit.
- Deletes suffix units instead of hiding them (setting displayable to None) - Calls deleteUnitSafely to check for unit dependacies, deleting the unit, and cleaning cik
- isSuffixRelated function determines if a unit is a suffix unit based on unit type (Suffix Analyzed) or if the suffix field is filled in (Suffix Input) Refactor: - Altered suffix detection cases to call isSuffixRelated. Reduces code redundancy and accounts for Suffix inputs. - Added code commentry - Modified suffixTypeUnitsToDelete to a simpler display
- Modified relatedConversions Fix cascade deletion walking backward into parent suffix units removeAdditionalConversionsAndUnits previously matched any conversion touching a suffix unit as either source or destination, regardless of direction. This caused cleanup started from a child unit (e.g. deleting "kg of X" -> "gallon") to walk backward through the parent-to-child conversion that created it, incorrectly cascading the delete up to the parent unit itself. Now only conversions where the unit is the source are followed, except for bidirectional conversions, where both directions are still valid since they genuinely work both ways. - deleteUnitSafely now occurs after removeAdditionalConversionsAndUnits
Unit tests for suffix unit deletion tests for: - Deletion of OED created units and their conversions - Clearing a dependent meter's unit ID to allow the auto-created unit to be deleted - Clearing converstions that reference OED created units - Clears a group's default graphic unit reference instead of blocking deletion of the unit it points to - Recursively cleaning up nested suffix chains - Prevention of deleting parent unit when deleting conversion from child unit - Deletion of bidirectional conversions relating to suffix units - Clearing cik rows before unit deletion - Prevention of deleting regular units when deleting a suffix related conversion
Member
|
@BunnyBea83 Thank you for this PR. It will take me about a week to get to review this. The description seems to be fine from my quick review. |
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.
Description
This PR solves OED's opporations for deleting conversions involving suffix units. Upon deletion of a suffix unit related conversion, OED created units and related conversions will be cascade deleted. UI warnings are inplace to notify the user of units and conversions that will be deleted, and groups/meters that will be affected by the deletion. This PR builds off of PR #1561 and PR #1470.
Key improvements:
Partly Addresses #1448
Type of change
Checklist
Limitations
Multi-hop-generated suffix units are not yet covered by this cascade delete since it likely needs a
design decision before implementation.
This PR resolves cascade deletion for the direct/single-hop case (deleting a
conversion from a suffix root, or from an auto-created child, correctly
cleans up what it should). It does not yet handle units auto-created via
multi-hop paths (e.g. suffix unit → new auto-created unit→ further conversion). Since OED always attaches such units
directly to the root rather than the intermediate unit, deleting the
intermediate conversion currently leaves these orphaned. Possible implementations could include either a re-walk of valid paths after delete, or tracking explicit provenance on auto-created units, both of
which are a larger design change than this PR's scope. Flagging for
follow-up discussion with maintainers.
Before Deletion of multi-hop path 'metric Ton of TestUnit -> gallon'
After Deletion of multi-hop path
Deletion of TestUnit -> kg removes all OED created units