cleanerversion icon indicating copy to clipboard operation
cleanerversion copied to clipboard

Add a time_version method to VersionManager

Open brki opened this issue 10 years ago • 6 comments

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.

brki avatar Nov 21 '14 10:11 brki

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

maennel avatar Jan 30 '15 13:01 maennel

I don't really like time_version as a method name though. version_as_of(..) perhaps?

brki avatar Jan 30 '15 16:01 brki

+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 .

maennel avatar Jan 30 '15 16:01 maennel

Any news on this ? I'm +1 for version_as_of(...) as well :)

jsenecal avatar Oct 07 '15 15:10 jsenecal

@brki Did you start work on this, already?

maennel avatar Oct 18 '15 15:10 maennel

No, not at all. Go ahead if you feel like it.

brki avatar Oct 19 '15 07:10 brki