bruth / django-tracking2

django-tracking2 tracks the length of time visitors and registered users spend on your site. Although this will work for websites, this is more applicable to web _applications_ with registered users. This does not replace (nor intend) to replace client-side analytics which is great for understanding aggregate flow of page views.
BSD 2-Clause "Simplified" License
205 stars 67 forks source link

Default start/end dates README suggestion #28

Closed smclenithan closed 9 years ago

smclenithan commented 10 years ago

Was a little confused by the default state of the dashboard. Currently if you do not specify the GET params 'start' and 'end' as yyy-mm-dd formatted dates (ex: https://www.example.com/tracking/?start=2013-11-1&end=2013-11-30) the dashboard will say there are no stats to show. I think this should, at the very least default to something and maybe mention it in the README. As far as I can see the start and end params are not mentioned anywhere, I only found this by reading the source.

Lines 16 and 17 of views.py appear to be the culprit:

    if not date_str:
        return

This causes the model queries to return empty sets of stats.

I decided to use the upper variable to determine what date to automatically calculate since that appears how it is used elsewhere anyway.

In place of the original lines 16 and 17 I am now using:

    if not date_str:
        if not upper:
            return date.today() - timedelta(days=7)
        else:
            return date.today()

The 7 days value was completely arbitrary, but you get the idea.