cleanerversion
cleanerversion copied to clipboard
Add a time_version method to VersionManager
previous_version, next_version, and current_version already exist. It would make sense to add a method to get the given object at a specific time, returning None if no such version existed.
Then it would be possible to write:
Foo.objects.time_version(foo_object, as_of_time)
Instead of:
Foo.objects.as_of(as_of_time).filter(identity=foo_object.identity).first()
And it would allow optimizing it to return the same object if the asked-for time lies in the given object's validity period.
In the context of mixing versionable and non-versionable models, it would also be useful to jump to another object version directly from a given object version; e.g.:
foo_old = foo.time_version(as_of_time)
instead of running
foo_old = foo.__class__.objects.as_of(as_of_time).get(identity=foo.identity)
Basically, the same thing as mentioned by @brki
I don't really like time_version
as a method name though. version_as_of(..)
perhaps?
+1 for version_as_of(..) ;)
-Manuel
On Fri, Jan 30, 2015, 17:25 brki [email protected] wrote:
I don't really like time_version as a method name though. version_as_of(..) perhaps?
— Reply to this email directly or view it on GitHub https://github.com/swisscom/cleanerversion/issues/33#issuecomment-72227363 .
Any news on this ? I'm +1 for version_as_of(...) as well :)
@brki Did you start work on this, already?
No, not at all. Go ahead if you feel like it.