You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.
Queries for objects during a time interval should be possible.
Right now, objects at a specific point in time can be queried. If one needs objects that lived during a specific time interval, it gets difficult. CleanerVersion should help to do this by adding the following query possibility on VersionedManager and VersionedQuerySet:
start: a timestamp indicating the start of the time interval
end: a timestamp indicating the end of the time interval
unique: a boolean; if True, return the latest valid version of an object during a time interval; if False, return all versions of an object during a time interval; Default: False
inclusive: a boolean: if True, versions that either start or end (or both) during a time interval are considered; if False, only versions that start AND end during a time interval are considered; Default: True
The return value is, as usual an object of type VersionedQuerySet.
Some more details: inclusive set to True translates to the filtering expression version_start_date < interval_end_date AND version_end_date > interval_start_date, i.e. a version is part of the resulting QuerySet if it starts, ends or exists only during the interval. inclusive set to False translates to the filtering expression version_start_date >= interval_start_date AND version_start_date < interval_end_date AND version_end_date > interval_start_date AND version_end_date <= interval_end_date, i.e. a version is part of the resulting QuerySet if it starts AND ends during the specified time interval.
Related objects (either O2M, M2O or M2M) should also be limited by the above mentioned filters.
The text was updated successfully, but these errors were encountered:
Current status on brki/cleanerversion/interval-querying:
Works for queried models, including with the unique parameter for in_interval(). The unique parameter only works for Django 1.8+. Since Django 1.7 has been at EOL for quite a while already, this okay imho.
Still TODO:
make it work for relations
more testing (relations / complex queries with model spanning lookups, etc.)
tox testing (to cover python / django versions)
clarify use case for inclusive parameter
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Queries for objects during a time interval should be possible.
Right now, objects at a specific point in time can be queried. If one needs objects that lived during a specific time interval, it gets difficult. CleanerVersion should help to do this by adding the following query possibility on
VersionedManager
andVersionedQuerySet
:Model.objects.in_interval(start, end, unique=<bool>, inclusive=<bool>).filter(...)
Arguments are:
start
: a timestamp indicating the start of the time intervalend
: a timestamp indicating the end of the time intervalunique
: a boolean; if True, return the latest valid version of an object during a time interval; if False, return all versions of an object during a time interval; Default: Falseinclusive
: a boolean: if True, versions that either start or end (or both) during a time interval are considered; if False, only versions that start AND end during a time interval are considered; Default: TrueThe return value is, as usual an object of type VersionedQuerySet.
Some more details:
inclusive
set to True translates to the filtering expressionversion_start_date < interval_end_date AND version_end_date > interval_start_date
, i.e. a version is part of the resulting QuerySet if it starts, ends or exists only during the interval.inclusive
set to False translates to the filtering expressionversion_start_date >= interval_start_date AND version_start_date < interval_end_date AND version_end_date > interval_start_date AND version_end_date <= interval_end_date
, i.e. a version is part of the resulting QuerySet if it starts AND ends during the specified time interval.Related objects (either O2M, M2O or M2M) should also be limited by the above mentioned filters.
The text was updated successfully, but these errors were encountered: