__author__ = 'ankesh'
from .models import BenchmarkLogs, MachineInfo
from django.db.models import Sum, Avg


def avgVGRvsProcessor():
    data_dict = {'chart_title': "Average VGR Rating vs Processor Family",
                 'chart_type': "bar",
                 'xAxis_title_text': "Processor Family",
                 'yAxis_title_text': "Average VGR Rating",
                 'categories': [],
                 'values': []}

    distinct_categories_dict = MachineInfo.objects.values('vendor_id').distinct()
    for category in distinct_categories_dict:
        data_dict['categories'].append(category['vendor_id'])
    for processor in data_dict['categories']:
        approx_vgr_dict =  MachineInfo.objects.filter(vendor_id=processor).aggregate(Avg('benchmark__approx_vgr'))
        data_dict['values'].append(approx_vgr_dict['benchmark__approx_vgr__avg'])
    return data_dict

#if __name__ == "main":
#   avgVGRvsProcessor()

@@ -123,16 +123,22 @@
 rocessor
+Family
 ():%0A    
@@ -931,8 +931,1513 @@
 essor()%0A
+%0A%0Adef avgVGRvsOSType():%0A    data_dict = %7B'chart_title': %22Average VGR Rating vs Operating System Type%22,%0A                 'chart_type': %22bar%22,%0A                 'xAxis_title_text': %22Average VGR Rating%22,%0A                 'yAxis_title_text': %22Operating System Type%22,%0A                 'categories': %5B%5D,%0A                 'values': %5B%5D%7D%0A    distinct_categories_dict = MachineInfo.objects.values('ostype').distinct()%0A    for category in distinct_categories_dict:%0A        data_dict%5B'categories'%5D.append(category%5B'ostype'%5D)%0A    for system in data_dict%5B'categories'%5D:%0A        approx_vgr_dict =  MachineInfo.objects.filter(ostype=system).aggregate(Avg('benchmark__approx_vgr'))%0A        data_dict%5B'values'%5D.append(approx_vgr_dict%5B'benchmark__approx_vgr__avg'%5D)%0A    return data_dict%0A%0A%0Adef avgVGRvsNCores():%0A    data_dict = %7B'chart_title': %22Average VGR Rating vs Number of Cores%22,%0A                 'chart_type': %22bar%22,%0A                 'xAxis_title_text': %22Average VGR Rating%22,%0A                 'yAxis_title_text': %22Number of CPUs%22,%0A                 'categories': %5B%5D,%0A                 'values': %5B%5D%7D%0A    distinct_number_dict = MachineInfo.objects.values('cores').distinct()%0A    for number in distinct_number_dict:%0A        data_dict%5B'categories'%5D.append(number%5B'cores'%5D)%0A    for number in data_dict%5B'categories'%5D:%0A        approx_vgr_dict =  MachineInfo.objects.filter(cores=number).aggregate(Avg('benchmark__approx_vgr'))%0A        data_dict%5B'values'%5D.append(approx_vgr_dict%5B'benchmark__approx_vgr__avg'%5D)%0A    return data_dict

Add aggregation codes for two more plots