refactor: improve sync merging categories#1559
Open
kaiserbh wants to merge 6 commits intojobobby04:masterfrom
Open
refactor: improve sync merging categories#1559kaiserbh wants to merge 6 commits intojobobby04:masterfrom
kaiserbh wants to merge 6 commits intojobobby04:masterfrom
Conversation
For legacy and migration we should assign uid on insert, and modify existing one as well in the migration.
Add version, uid and lastModifiedAt fields to Category model to allow syncing.
Improve the category merging logic by matching using UIDs first, with a fallback to matching by name for legacy remote categories. Previously, categories were only matched by name, which could lead to incorrect merges if names were changed. This change ensures more accurate synchronization by prioritizing the unique identifier. Conflict resolution is now based on the `version` field, and logging has been added for better visibility into the merging process.
If a category with the same UID exists, update it instead of creating a new one. Fallback to matching by name if no UID match is found.
This make sure the version is consistent, and it's not accidentally appended by the trigger, if it does then one device will always be ahead, than previous, and they need to make multiple changes to increase the version.
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.
Improve the category merging logic by matching using UIDs first, with a fallback to matching by name for legacy remote categories.
Previously, categories were only matched by name, which could lead to incorrect merges if names were changed. This change ensures more accurate synchronisation by prioritising the unique identifier.
It works perfectly now, we can even change the order and it won't fail like before and if a category has been renamed it will rename it instead of creating a new category.
should close: syncyomi/syncyomi#70