terrible title, but let me explain: I have this django model containing the timestamp (date) and the log attribute - fe the number of users consuming some resource - (value).
class Viewers(models.Model):
date = models.DateTimeField()
value = models.IntegerField()
for every 10 seconds, the table contains the number of users. something like that:
| date | value |
|------|-------|
| t1 | 15 |
| t2 | 18 |
| t3 | 27 |
| t4 | 25 |
| .. | .. |
| t30 | 38 |
| t31 | 36 |
| .. | .. |
Now I want to generate different statistics from this data, each with a different resolution. FE for the last day’s graph, I don’t need a resolution of 10 seconds, so I want 5-minute steps (which are built by averaging the values (or maybe the dates) of the rows from t1 to t29, t30 to t59 ...), so I will get:
| date | value |
|------|-------|
| t15 | 21 |
| t45 | 32 |
| .. | .. |
(, 5 ). django orm/queryset api, , sql?