diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-03-10 17:38:00 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-16 17:44:09 +0000 |
commit | 193989cec807120307cda50c616118dca4025b8a (patch) | |
tree | 4e63be374877262cbc2e6d985454b677e3acd31b /bitbake/lib/toaster/orm | |
parent | 2b629e618227632bc8b774796d760904fcca92f4 (diff) | |
download | poky-193989cec807120307cda50c616118dca4025b8a.tar.gz |
bitbake: toastergui: tables display optimizations
This patch brings in a new set of optimizations in the tables pages,
with the focus of reducing the number of SQL queries performed per
row.
(Bitbake rev: a1ad86febb9d8a4ee7f15aa726f267d64b8e0dc4)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index b941d4ab20..2132f8799c 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -182,7 +182,7 @@ class Project(models.Model): | |||
182 | 182 | ||
183 | # returns a set of layer-equivalent set of layers already in project | 183 | # returns a set of layer-equivalent set of layers already in project |
184 | def projectlayer_equivalent_set(self): | 184 | def projectlayer_equivalent_set(self): |
185 | return [j for i in [x.layercommit.get_equivalents_wpriority(self) for x in self.projectlayer_set.all()] for j in i] | 185 | return [j for i in [x.layercommit.get_equivalents_wpriority(self) for x in self.projectlayer_set.all().select_related("up_branch")] for j in i] |
186 | 186 | ||
187 | def schedule_build(self): | 187 | def schedule_build(self): |
188 | from bldcontrol.models import BuildRequest, BRTarget, BRLayer, BRVariable, BRBitbake | 188 | from bldcontrol.models import BuildRequest, BRTarget, BRLayer, BRVariable, BRBitbake |
@@ -545,11 +545,6 @@ class Recipe(models.Model): | |||
545 | bugtracker = models.URLField(blank=True) | 545 | bugtracker = models.URLField(blank=True) |
546 | file_path = models.FilePathField(max_length=255) | 546 | file_path = models.FilePathField(max_length=255) |
547 | 547 | ||
548 | def get_vcs_link_url(self): | ||
549 | if self.layer_version.layer.vcs_web_file_base_url is None: | ||
550 | return "" | ||
551 | return self.layer_version.layer.vcs_web_file_base_url.replace('%path%', self.file_path).replace('%branch%', self.layer_version.up_branch.name) | ||
552 | |||
553 | def get_layersource_view_url(self): | 548 | def get_layersource_view_url(self): |
554 | if self.layer_source is None: | 549 | if self.layer_source is None: |
555 | return "" | 550 | return "" |
@@ -708,8 +703,6 @@ class LayerIndexLayerSource(LayerSource): | |||
708 | self.sourcetype = LayerSource.TYPE_LAYERINDEX | 703 | self.sourcetype = LayerSource.TYPE_LAYERINDEX |
709 | 704 | ||
710 | def get_object_view(self, branch, objectype, upid): | 705 | def get_object_view(self, branch, objectype, upid): |
711 | if self != branch.layer_source: | ||
712 | raise Exception("Invalid branch specification") | ||
713 | return self.apiurl + "../branch/" + branch.name + "/" + objectype + "/?q=" + str(upid) | 706 | return self.apiurl + "../branch/" + branch.name + "/" + objectype + "/?q=" + str(upid) |
714 | 707 | ||
715 | def update(self): | 708 | def update(self): |
@@ -1044,14 +1037,6 @@ class Layer_Version(models.Model): | |||
1044 | 1037 | ||
1045 | def get_equivalents_wpriority(self, project): | 1038 | def get_equivalents_wpriority(self, project): |
1046 | """ Returns an ordered layerversion list that satisfies a LayerVersionDependency using the layer name and the current Project Releases' LayerSource priority """ | 1039 | """ Returns an ordered layerversion list that satisfies a LayerVersionDependency using the layer name and the current Project Releases' LayerSource priority """ |
1047 | def _get_ls_priority(ls): | ||
1048 | try: | ||
1049 | # if there is no layer source, we have minus infinite priority, as we don't want this layer selected | ||
1050 | if ls == None: | ||
1051 | return -10000 | ||
1052 | return ls.releaselayersourcepriority_set.get(release=project.release).priority | ||
1053 | except ReleaseLayerSourcePriority.DoesNotExist: | ||
1054 | raise | ||
1055 | 1040 | ||
1056 | # layers created for this project, or coming from a build inthe project | 1041 | # layers created for this project, or coming from a build inthe project |
1057 | query = Q(project = project) | Q(build__project = project) | 1042 | query = Q(project = project) | Q(build__project = project) |
@@ -1062,8 +1047,27 @@ class Layer_Version(models.Model): | |||
1062 | # or we have a layer in the project that's similar to mine (See the layer.name constraint below) | 1047 | # or we have a layer in the project that's similar to mine (See the layer.name constraint below) |
1063 | query |= Q(projectlayer__project=project) | 1048 | query |= Q(projectlayer__project=project) |
1064 | 1049 | ||
1065 | return sorted( | 1050 | candidate_layer_versions = list(Layer_Version.objects.filter(layer__name = self.layer.name).filter(query).select_related('layer_source', 'layer', 'up_branch').order_by("-id")) |
1066 | Layer_Version.objects.filter(layer__name = self.layer.name).filter(query).select_related('layer_source', 'layer').order_by("-id"), | 1051 | |
1052 | # optimization - if we have only one, we don't need no stinking sort | ||
1053 | if len(candidate_layer_versions) == 1: | ||
1054 | return candidate_layer_versions | ||
1055 | |||
1056 | # raise Exception(candidate_layer_versions) | ||
1057 | |||
1058 | release_priorities = map(lambda x: (x.layer_source_id, x.priority), project.release.releaselayersourcepriority_set.all().order_by("-priority")) | ||
1059 | |||
1060 | |||
1061 | def _get_ls_priority(ls): | ||
1062 | # if there is no layer source, we have minus infinite priority, as we don't want this layer selected | ||
1063 | if ls == None: | ||
1064 | return -10000 | ||
1065 | try: | ||
1066 | return release_priorities[ls.id] | ||
1067 | except IndexError: | ||
1068 | raise Exception("Unknown %d %s" % (ls.id, release_priorities)) | ||
1069 | |||
1070 | return sorted( candidate_layer_versions , | ||
1067 | key = lambda x: _get_ls_priority(x.layer_source), | 1071 | key = lambda x: _get_ls_priority(x.layer_source), |
1068 | reverse = True) | 1072 | reverse = True) |
1069 | 1073 | ||