Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B10E7E00945; Sat, 2 May 2015 08:50:44 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [192.55.52.93 listed in list.dnswl.org] Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 37280E004F6 for ; Sat, 2 May 2015 08:50:40 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 02 May 2015 08:50:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,355,1427785200"; d="scan'208";a="688936052" Received: from linux.intel.com ([10.23.219.25]) by orsmga001.jf.intel.com with ESMTP; 02 May 2015 08:50:39 -0700 Received: from vmed.fi.intel.com (vmed.fi.intel.com [10.237.72.65]) by linux.intel.com (Postfix) with ESMTP id 3545C6A408D; Sat, 2 May 2015 08:50:10 -0700 (PDT) From: Ed Bartosh To: toaster@yoctoproject.org Date: Sat, 2 May 2015 18:50:34 +0300 Message-Id: <1430581834-3223-1-git-send-email-ed.bartosh@linux.intel.com> X-Mailer: git-send-email 2.1.4 Subject: [review-request][PATCH] bitbake: toastergui: decrease load time for configuration page X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 May 2015 15:50:44 -0000 Used __in field lookup for QuerySet to get build variables faster. [YOCTO #6691] Signed-off-by: Ed Bartosh --- bitbake/lib/toaster/toastergui/views.py | 46 +++++++-------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index e7110c8..c22b24d 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -1267,43 +1267,15 @@ def recipes(request, build_id): def configuration(request, build_id): template = 'configuration.html' - variables = Variable.objects.filter(build=build_id) - - def _get_variable_or_empty(variable_name): - from django.core.exceptions import ObjectDoesNotExist - try: - return variables.get(variable_name=variable_name).variable_value - except ObjectDoesNotExist: - return '' - - BB_VERSION=_get_variable_or_empty(variable_name='BB_VERSION') - BUILD_SYS=_get_variable_or_empty(variable_name='BUILD_SYS') - NATIVELSBSTRING=_get_variable_or_empty(variable_name='NATIVELSBSTRING') - TARGET_SYS=_get_variable_or_empty(variable_name='TARGET_SYS') - MACHINE=_get_variable_or_empty(variable_name='MACHINE') - DISTRO=_get_variable_or_empty(variable_name='DISTRO') - DISTRO_VERSION=_get_variable_or_empty(variable_name='DISTRO_VERSION') - TUNE_FEATURES=_get_variable_or_empty(variable_name='TUNE_FEATURES') - TARGET_FPU=_get_variable_or_empty(variable_name='TARGET_FPU') - - targets = Target.objects.filter(build=build_id) - - context = { - 'objectname': 'configuration', - 'object_search_display':'variables', - 'filter_search_display':'variables', - 'build': Build.objects.get(pk=build_id), - 'BB_VERSION':BB_VERSION, - 'BUILD_SYS':BUILD_SYS, - 'NATIVELSBSTRING':NATIVELSBSTRING, - 'TARGET_SYS':TARGET_SYS, - 'MACHINE':MACHINE, - 'DISTRO':DISTRO, - 'DISTRO_VERSION':DISTRO_VERSION, - 'TUNE_FEATURES':TUNE_FEATURES, - 'TARGET_FPU':TARGET_FPU, - 'targets':targets, - } + var_names = ('BB_VERSION', 'BUILD_SYS', 'NATIVELSBSTRING', 'TARGET_SYS', + 'MACHINE', 'DISTRO', 'DISTRO_VERSION', 'TUNE_FEATURES', 'TARGET_FPU') + context = dict(Variable.objects.filter(build=build_id, variable_name__in=var_names)\ + .values_list('variable_name', 'variable_value')) + context.update({'objectname': 'configuration', + 'object_search_display':'variables', + 'filter_search_display':'variables', + 'build': Build.objects.get(pk=build_id), + 'targets': Target.objects.filter(build=build_id)}) return render(request, template, context) -- 2.1.4