This repository has been archived by the owner on Apr 14, 2019. It is now read-only.
WIP: add generic_dedupe module for tracking dedupe changes. #211
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.
To do:
This is an alternate approach to #201 - tracking deduping, allowing manual deduping through the admin interface, and making deduping reversible.
The approach here is:
true_model_id
field for any entry that can be deduped.true_model_id
is set, all foreign keys onto that model are automagically migrated to the "true model", and aDedupeLogEntry
is added for each foreign key that was changed.true_model_id
is changed, then the oldDedupeLogEntry
values are used to revert to the original model, and the newtrue_model_id
is applied.I've tested this manually and it seems to work (set / reset / unset). I will work on unit tests, but I wanted to get a basic version out there for discussion first.
The code isn't huge, but it's complicated and likely incomplete. The goal here is to start with an MVP that works for our core use-cases.
The models used in this code are:
DedupeMixin
- adds thetrue_model_id
field and provides afiltered_objects
manager that gives a list of rows that are core data / not unwanted variants.DedupeLogEntry
- extendsLogEntry
and keeps track of info to make dedupe reversible.Finally, some screen shots:
Setting "true model" to an alternate city:
Dedupe log entries auto-created, showing the foreign keys set by the above manual setting.
Unset the "true model", and ...
The foreign keys are reset (not shown here), and the log entries are deleted: