omniport-backend icon indicating copy to clipboard operation
omniport-backend copied to clipboard

Use `DateRangeField` offered by `django.contrib.postgres` instead of primitive start and end date

Open dhruvkb opened this issue 6 years ago • 0 comments

The mixins PeriodMixin and BlurryPeriodMixin use the start and end date very primitively. They might be replaced with a DateRangeField offered by the django.contrib.postgres package, which has very efficient range overlap functions (currently written by hand in the model).

The goal is to understand if DateRangeField suits all our usecases and if it does, rewrite the period mixins to use the more advanced method of dealing with dateranges. Even if it doesn't psycopg2.extras provides DateTimeTZRange and __contained_by lookup that can be used for more efficient checking of whether the range is past, current or due.

dhruvkb avatar Nov 11 '18 09:11 dhruvkb