def set_aggregates(self, force=False):
        aggregates = {}
        
        if not self.avg_time or force:
            aggregates["avg_time"] = models.Avg('timer_total')
        if not self.avg_cpu_time or force:
            aggregates["avg_cpu_time"] = models.Avg('timer_cputime')
        if not self.avg_sql_time or force:
            aggregates["avg_sql_time"] = models.Avg('sql_time')
        if not self.avg_sql_queries or force:
            aggregates["avg_sql_queries"] = models.Avg('sql_num_queries')
        if not self.total_sql_queries or force:
            aggregates["total_sql_queries"] = models.Sum('sql_num_queries')
        if not self.max_sql_queries or force:
            aggregates["max_sql_queries"] = models.Max('sql_num_queries')
        if not self.total_requests or force:
            aggregates["total_requests"] = models.Count('pk')
        
        if aggregates:
            aggregated = self.records.aggregate(**aggregates)
            
            for key, value in aggregated.items():
                setattr(self, key, value)
Sets any aggregates that haven't been generated yet, or recalculates
dataset/ETHPy150Open lincolnloop/django-debug-logging/debug_logging/models.py/TestRun.set_aggregates