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 Jun 1, 2021. It is now read-only.
I want to plot the number of instances in the database over time. Now in my case the number of objects can only increase, never decrease, so an easy way to transform the query into something Google Charts can understand is to just annotate each row with its index in the queryset and order things by date.
Say we have a LogEntry object that has a timestamp. Now I want to plot the number of log entries in the databaase over time. I can do that by using the timestamp as X and the number of entries in the DB at that point in time as Y value - which is, in this case, the index of that entry in the queryset.
------+------+-----------+-------------
rowno | id | timestamp | log content
------+------+-----------+-------------
1 | 42 | 2013/12/5 | Some text
2 | 108 | 2013/12/6 | Some text
3 | 5387 | 2013/12/9 | Some text
Number of entries in DB at 2013/12/5: 1
Number of entries in DB at 2013/12/6: 2
Number of entries in DB at 2013/12/9: 3
Aha, right!
Well, that sounds like a good idea =)
I like the idea of having map kwarg which takes a function argument and yields the results.
It should be implemented as a general purpose function though.
If you have a good idea implementation-wise, please share your thoughts (or submit a pull request ;)).
I'm a little busy at work these days so I don't have time to look into it now, but I like the idea.
Cheers!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I need a graph that shows the number of objects over time. The objects have a date(time) field.
Unfortunately, there's no uniform way of annotating rows with their row number in Django/SQL.
Idea: Provide some way to plug in a transformation on the rows/queryset fetched from the database. For example
The text was updated successfully, but these errors were encountered: