#25339: Aggregation and annotation by time period and intervals (by month, week,
day, hour, etc)
-------------------------------------+-------------------------------------
Reporter: malefice | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: QuerySet.extra | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by malefice):
I do not think that excerpt does the same functionality mine does. It
seems that it only filters for the year 2015, extracts the month number,
and then performs a 'GROUP BY' based on the month number. It does not
generate an actual timeseries that can easily be parsed by javascript and
charting libraries.
My excerpt outputs actual time periods based on a range of dates with
specific intervals/frequency. If for example, the `start_date` is
2015-01-01, `end_date` is 2015-07-07, and `frequency` is month, it will
aggregate the results that match the date range and group them by month
dates like so: 2015-01-01, 2015-02-01, 2015-03-01, ... 2015-07-01.
If the `frequency` is hour, then it will output each and every hour like
so: 2015-01-01 00:00:00, 2015-01-01 01:00:00, 2015-01-01 02:00:00, ...
2015-05-01 00:00:00, 2015-05-01 01:00:00 , ... , 2015-07-07 22:00:00, and
2015-07-07 23:00:00. You will have a column containing the actual
timeseries.
One can only do that efficiently in PostgreSQL by using the `DATE_TRUNC`
function, and I looked in the source code, but it does not seem to be used
in anywhere that might resemble something like my excerpt. I think it is
possible to write a custom Transform for that, but it would be nice to
have it ready out of the box. At least in my case, projects always involve
aggregating and presenting data with a timeseries.
--
Ticket URL: <https://code.djangoproject.com/ticket/25339#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.75fe177da9afc60863b3665f7b519a1e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.