This seems okay at first glance, though I wonder if an enum-like object 
might be better than magic int/boolean values. Something like:

class ApproximateWith(object):
    NONE = 0
    YEARS = 1
    MONTHS = 2
    DAYS = 3

Do you think a separate ModelAdmin attribute better than allowing something 
like:

date_hierarchy = ('pub_date', ApproximateWith.YEARS)

Values that can be string or tuple have contributed to bugs in the past, 
but I thought it might be worth proposing.

On Saturday, August 29, 2015 at 4:50:20 PM UTC-4, Gavin Wahl wrote:
>
> I'm going to fix ticket #23242 by adding an option to approximate the 
> date_hierarchy options instead of calculating them exactly. The 
> implementation is straightforward but I'm not sure what the interface 
> should be. 
>
> The basic idea is instead of doing `SELECT DISTINCT date_trunc('year', 
> created_at) FROM table`, then a date_trunc('month', created_at) to get the 
> list of months, and so on, you can find the range with `SELECT 
> date_trunc('year', max(created_at)), date_trunc('year', min(creeated_at))` 
> and just assume that every year/month/day in between is filled in.
>
> How should this feature be enabled? Should it be possible to approximate 
> the year list, but once you've selected the year switch to exact? I'm 
> thinking something like:
>
> - approximate_date_hierarchy = False # default
> - approximate_date_hierarchy = 1 # approximate years only
> - approximate_date_hierarchy = 2 # approximate months and years
> - approximate_date_hierarchy = 3 or True # approximate days, months, and 
> years
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/9152eb8c-7c47-4a35-a89b-278fd0aa2fc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to