Effective Week Statistics for QuerySet

I am working on an open source Django time tracking application, Djime , and I'm trying to come up with a more efficient way to get statistics. So far, we had a rather long procedural code that would receive all TimeSlices for a certain period of time and put them together in a huge nested mess in the list / dictionaries.

What I would like to do is create a more efficient system - an object or function that will execute the QuerySet from TimeSlices and map them using the user, task and / or day.

Our model looks like this (simplified):

class TimeSlice(models.Model):
    task = models.ForeignKey(Task)
    user = models.ForeignKey(User)
    begin = models.DateTimeField(default=datetime.datetime.now)
    duration = models.PositiveIntegerField(null=True, blank=True) # Num. of seconds
    note = models.TextField(null=True, blank=True)
+3
source share
1 answer

It looks like you want the aggregation feature to appear in Django 1.1. It is already available in recent checks from the trunk.

See here for an explanation.

0
source

Source: https://habr.com/ru/post/1710314/


All Articles