diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-03-10 18:55:54 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-16 17:44:10 +0000 |
commit | e4ff3eadfa055b58e1d12cb0b8afc0202d4be3d7 (patch) | |
tree | a6176721d2fb6368a6753f89f9d4cf81f1ad3047 /bitbake/lib | |
parent | c4722084b60d43c29ab0db2728d7998a403107ad (diff) | |
download | poky-e4ff3eadfa055b58e1d12cb0b8afc0202d4be3d7.tar.gz |
bitbake: toastergui: improve toaster suggestion
Improving the suggestions by ordering entries
based on position of the search string.
Speed improvements in suggestion calls.
[YOCTO #7152]
(Bitbake rev: 61b0f0e46a589af9d669e52d4cec656bbd0d0057)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 541b16ab1d..807bf9bee1 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2259,7 +2259,7 @@ if toastermain.settings.MANAGED: | |||
2259 | # return all project settings | 2259 | # return all project settings |
2260 | return HttpResponse(jsonfilter( { | 2260 | return HttpResponse(jsonfilter( { |
2261 | "error": "ok", | 2261 | "error": "ok", |
2262 | "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.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name}}, prj.projectlayer_set.all().select_related("layer").order_by("id")), | 2262 | "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.pk,)), "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name}}, prj.projectlayer_set.all().select_related("layer").order_by("id")), |
2263 | "builds" : _project_recent_build_list(prj), | 2263 | "builds" : _project_recent_build_list(prj), |
2264 | "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), | 2264 | "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), |
2265 | "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value}, | 2265 | "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value}, |
@@ -2356,11 +2356,13 @@ if toastermain.settings.MANAGED: | |||
2356 | # returns targets provided by current project layers | 2356 | # returns targets provided by current project layers |
2357 | if request.GET['type'] == "targets": | 2357 | if request.GET['type'] == "targets": |
2358 | search_token = request.GET.get('value','') | 2358 | search_token = request.GET.get('value','') |
2359 | queryset_all = Recipe.objects.filter(Q(name__icontains=search_token) | Q(layer_version__layer__name__icontains=search_token) ) | 2359 | queryset_all = Recipe.objects.filter(layer_version__layer__name__in = [x.layercommit.layer.name for x in prj.projectlayer_set.all().select_related("layercommit__layer")]).filter(Q(name__icontains=search_token) | Q(layer_version__layer__name__icontains=search_token)) |
2360 | layer_equivalent_set = [] | 2360 | |
2361 | for i in prj.projectlayer_set.all(): | 2361 | # layer_equivalent_set = [] |
2362 | layer_equivalent_set += i.layercommit.get_equivalents_wpriority(prj) | 2362 | # for i in prj.projectlayer_set.all().select_related("layercommit__up_branch", "layercommit__layer"): |
2363 | queryset_all = queryset_all.filter(layer_version__in = layer_equivalent_set) | 2363 | # layer_equivalent_set += i.layercommit.get_equivalents_wpriority(prj) |
2364 | |||
2365 | # queryset_all = queryset_all.filter(layer_version__in = layer_equivalent_set) | ||
2364 | 2366 | ||
2365 | # if we have more than one hit here (for distinct name and version), max the id it out | 2367 | # if we have more than one hit here (for distinct name and version), max the id it out |
2366 | queryset_all_maxids = queryset_all.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id') | 2368 | queryset_all_maxids = queryset_all.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id') |
@@ -2368,8 +2370,13 @@ if toastermain.settings.MANAGED: | |||
2368 | 2370 | ||
2369 | 2371 | ||
2370 | return HttpResponse(jsonfilter({ "error":"ok", | 2372 | return HttpResponse(jsonfilter({ "error":"ok", |
2371 | "list" : map ( lambda x: {"id": x.pk, "name": x.name, "detail":"[" + x.layer_version.layer.name +"]"}, | 2373 | "list" : |
2374 | # 7152 - sort by token position | ||
2375 | sorted ( | ||
2376 | map ( lambda x: {"id": x.pk, "name": x.name, "detail":"[" + x.layer_version.layer.name +"]"}, | ||
2372 | queryset_all[:8]), | 2377 | queryset_all[:8]), |
2378 | key = lambda i: i["name"].find(search_token) if i["name"].find(search_token) > -1 else 9999, | ||
2379 | ) | ||
2373 | 2380 | ||
2374 | }), content_type = "application/json") | 2381 | }), content_type = "application/json") |
2375 | 2382 | ||
@@ -2383,7 +2390,12 @@ if toastermain.settings.MANAGED: | |||
2383 | queryset_all = queryset_all.filter(Q(name__icontains=search_token) | Q(description__icontains=search_token)) | 2390 | queryset_all = queryset_all.filter(Q(name__icontains=search_token) | Q(description__icontains=search_token)) |
2384 | 2391 | ||
2385 | return HttpResponse(jsonfilter({ "error":"ok", | 2392 | return HttpResponse(jsonfilter({ "error":"ok", |
2386 | "list" : map ( lambda x: {"id": x.pk, "name": x.name, "detail":"[" + x.layer_version.layer.name+ "]"}, queryset_all[:8]) | 2393 | "list" : |
2394 | # 7152 - sort by the token position | ||
2395 | sorted ( | ||
2396 | map ( lambda x: {"id": x.pk, "name": x.name, "detail":"[" + x.layer_version.layer.name+ "]"}, queryset_all[:8]), | ||
2397 | key = lambda i: i["name"].find(search_token) if i["name"].find(search_token) > -1 else 9999, | ||
2398 | ) | ||
2387 | }), content_type = "application/json") | 2399 | }), content_type = "application/json") |
2388 | 2400 | ||
2389 | # returns all projects | 2401 | # returns all projects |