summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-02-17 17:24:29 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-20 12:58:19 +0000
commite133fbf301ee14c93db9b9bc930ab2463122544c (patch)
treeffefb4ce1a41a8d3838d19f70e672fbd38150974 /bitbake/lib/toaster/toastergui/views.py
parent9c358bd1d7a301e7aee3676871310d50c336ba07 (diff)
downloadpoky-e133fbf301ee14c93db9b9bc930ab2463122544c.tar.gz
bitbake: toasterui: UI query performance improvements
We reduce the number of queries by using "select_related" to bring in more data in a single query. Improvements in project page refresh, recipes table and tasks table. (Bitbake rev: eefdae12120f879b555ba0a353277a18675eecbc) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index eb323ec81d..a2e92068c5 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -75,8 +75,9 @@ def _project_recent_build_list(prj):
75 'build_time_page_url': reverse('buildtime', args=(y.pk,)), 75 'build_time_page_url': reverse('buildtime', args=(y.pk,)),
76 "errors": y.errors_no, 76 "errors": y.errors_no,
77 "warnings": y.warnings_no, 77 "warnings": y.warnings_no,
78 "completeper": y.completeper(), 78 "completeper": y.completeper() if y.outcome == Build.IN_PROGRESS else "0",
79 "eta": y.eta().strftime('%s')+"000"}, Build.objects.filter(buildrequest = x)), 79 "eta": y.eta().strftime('%s')+"000" if y.outcome == Build.IN_PROGRESS else "0",
80 }, Build.objects.filter(buildrequest = x)),
80 }, list(prj.buildrequest_set.filter(Q(state__lt=BuildRequest.REQ_COMPLETED) or Q(state=BuildRequest.REQ_DELETED)).order_by("-pk")) + 81 }, list(prj.buildrequest_set.filter(Q(state__lt=BuildRequest.REQ_COMPLETED) or Q(state=BuildRequest.REQ_DELETED)).order_by("-pk")) +
81 list(prj.buildrequest_set.filter(state__in=[BuildRequest.REQ_COMPLETED, BuildRequest.REQ_FAILED]).order_by("-pk")[:3])) 82 list(prj.buildrequest_set.filter(state__in=[BuildRequest.REQ_COMPLETED, BuildRequest.REQ_FAILED]).order_by("-pk")[:3]))
82 83
@@ -828,6 +829,8 @@ def tasks_common(request, build_id, variant, task_anchor):
828 else: 829 else:
829 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order') 830 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order')
830 831
832 queryset = queryset.select_related("recipe", "build")
833
831 # compute the anchor's page 834 # compute the anchor's page
832 if anchor: 835 if anchor:
833 request.GET = request.GET.copy() 836 request.GET = request.GET.copy()
@@ -1023,14 +1026,14 @@ def recipes(request, build_id):
1023 if retval: 1026 if retval:
1024 return _redirect_parameters( 'recipes', request.GET, mandatory_parameters, build_id = build_id) 1027 return _redirect_parameters( 'recipes', request.GET, mandatory_parameters, build_id = build_id)
1025 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe) 1028 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe)
1026 queryset = Recipe.objects.filter(layer_version__id__in=Layer_Version.objects.filter(build=build_id)) 1029 queryset = Recipe.objects.filter(layer_version__id__in=Layer_Version.objects.filter(build=build_id)).select_related("layer_version", "layer_version__layer")
1027 queryset = _get_queryset(Recipe, queryset, filter_string, search_term, ordering_string, 'name') 1030 queryset = _get_queryset(Recipe, queryset, filter_string, search_term, ordering_string, 'name')
1028 1031
1029 recipes = _build_page_range(Paginator(queryset, pagesize),request.GET.get('page', 1)) 1032 recipes = _build_page_range(Paginator(queryset, pagesize),request.GET.get('page', 1))
1030 1033
1031 # prefetch the forward and reverse recipe dependencies 1034 # prefetch the forward and reverse recipe dependencies
1032 deps = { }; revs = { } 1035 deps = { }; revs = { }
1033 queryset_dependency=Recipe_Dependency.objects.filter(recipe__layer_version__build_id = build_id) 1036 queryset_dependency=Recipe_Dependency.objects.filter(recipe__layer_version__build_id = build_id).select_related("depends_on", "recipe")
1034 for recipe in recipes: 1037 for recipe in recipes:
1035 deplist = [ ] 1038 deplist = [ ]
1036 for recipe_dep in [x for x in queryset_dependency if x.recipe_id == recipe.id]: 1039 for recipe_dep in [x for x in queryset_dependency if x.recipe_id == recipe.id]:
@@ -1804,7 +1807,7 @@ if toastermain.settings.MANAGED:
1804 (filter_string, search_term, ordering_string) = _search_tuple(request, BuildRequest) 1807 (filter_string, search_term, ordering_string) = _search_tuple(request, BuildRequest)
1805 # we don't display in-progress or deleted builds 1808 # we don't display in-progress or deleted builds
1806 queryset_all = buildrequests.exclude(state = BuildRequest.REQ_DELETED) 1809 queryset_all = buildrequests.exclude(state = BuildRequest.REQ_DELETED)
1807 queryset_all = queryset_all.annotate(Count('brerror')) 1810 queryset_all = queryset_all.select_related("build", "build__project").annotate(Count('brerror'))
1808 queryset_with_search = _get_queryset(BuildRequest, queryset_all, filter_string, search_term, ordering_string, '-updated') 1811 queryset_with_search = _get_queryset(BuildRequest, queryset_all, filter_string, search_term, ordering_string, '-updated')
1809 1812
1810 1813
@@ -2179,7 +2182,7 @@ if toastermain.settings.MANAGED:
2179 # return all project settings 2182 # return all project settings
2180 return HttpResponse(jsonfilter( { 2183 return HttpResponse(jsonfilter( {
2181 "error": "ok", 2184 "error": "ok",
2182 "layers" : map(lambda x: {"id": x.layercommit.pk, "orderid" : x.pk, "name" : x.layercommit.layer.name, "giturl" : x.layercommit.layer.vcs_url, "url": x.layercommit.layer.layer_index_url, "layerdetailurl": reverse("layerdetails", args=(x.layercommit.layer.pk,)), "branch" : { "name" : x.layercommit.up_branch.name, "layersource" : x.layercommit.up_branch.layer_source.name}}, prj.projectlayer_set.all().order_by("id")), 2185 "layers" : map(lambda x: {"id": x.layercommit.pk, "orderid" : x.pk, "name" : x.layercommit.layer.name, "giturl" : x.layercommit.layer.vcs_url, "url": x.layercommit.layer.layer_index_url, "layerdetailurl": reverse("layerdetails", args=(x.layercommit.layer.pk,)), "branch" : { "name" : x.layercommit.up_branch.name, "layersource" : x.layercommit.up_branch.layer_source.name}}, prj.projectlayer_set.all().select_related("layer").order_by("id")),
2183 "builds" : _project_recent_build_list(prj), 2186 "builds" : _project_recent_build_list(prj),
2184 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), 2187 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()),
2185 "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value}, 2188 "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value},