WIP: Some versioning refactor #1128
Draft
+584
−244
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.
This PR is not meant to be merged, but rather to evoke discussion.
The current versioning code is too complex. Here's some initial code to convey a different approach. Do let me know what you think.
The
InstanceDiff
would typically be the main entry point, so maybe start there if you want to build a mental modelThe main things to focus on is the code in the
versioning.py
file and the newversioning_fields
,get_versioned_field_value
andget_versioned_fields_for_display
methods.Basically, we need 1. a way to know which fields to get, 2. we need to get the values for those fields. Sometimes it's not just a simle
getattr
, but a more comlex query, or in the case of triggers where we want to fetch action params, we need to do that in this step. Lastly, method 3 is for display purposes.I think here we can do the same as we did with
VersionField
where we return a single wrapper that knows how to display the current value, but I still need to do that. Anycase, leaving this as-is for now.