aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-08-04 22:46:30 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-06 16:04:44 -0500
commitc4e7113dd09c11a8a661cbefc417fcfbc5d5f6af (patch)
tree8281f715ca6cdcd8872e14018d621a6e19980288 /bitbake
parentd3b9927a3cfc5adbfbb1fe88378ed8dde7644a8c (diff)
downloadopenembedded-core-contrib-c4e7113dd09c11a8a661cbefc417fcfbc5d5f6af.tar.gz
bitbake: toaster: orm Add util functions to return common querysets
We use these querysets when creating tables of results and also when we want to have a typeahead search. These can also form the basis of future API endpoints. (Bitbake rev: 2a10fecd985343802f0e99c6fff25c28980eee20) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/orm/models.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 3b72f802a0..4f07e37c52 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -20,7 +20,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.db import models
-from django.db.models import F, Q, Avg
+from django.db.models import F, Q, Avg, Max
from django.utils import timezone
from django.core.urlresolvers import reverse
@@ -195,6 +195,45 @@ class Project(models.Model):
def projectlayer_equivalent_set(self):
return self.compatible_layerversions().filter(layer__name__in = [x.layercommit.layer.name for x in self.projectlayer_set.all()]).select_related("up_branch")
+ def get_available_machines(self):
+ """ Returns QuerySet of all Machines which are provided by the
+ Layers currently added to the Project """
+ queryset = Machine.objects.filter(layer_version__in=self.projectlayer_equivalent_set)
+ return queryset
+
+ def get_all_compatible_machines(self):
+ """ Returns QuerySet of all the compatible machines available to the
+ project including ones from Layers not currently added """
+ compatible_layers = self.compatible_layerversions()
+
+ queryset = Machine.objects.filter(layer_version__in=compatible_layers)
+ return queryset
+
+ def get_available_recipes(self):
+ """ Returns QuerySet of all Recipes which are provided by the Layers
+ currently added to the Project """
+ project_layers = self.projectlayer_equivalent_set()
+ queryset = Recipe.objects.filter(layer_version__in = project_layers)
+
+ # Copied from get_all_compatible_recipes
+ search_maxids = map(lambda i: i[0], list(queryset.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id')))
+ queryset = queryset.filter(id__in=search_maxids).select_related('layer_version', 'layer_version__layer', 'layer_version__up_branch', 'layer_source')
+ # End copy
+
+ return queryset
+
+ def get_all_compatible_recipes(self):
+ """ Returns QuerySet of all the compatible Recipes available to the
+ project including ones from Layers not currently added """
+ compatible_layerversions = self.compatible_layerversions()
+ queryset = Recipe.objects.filter(layer_version__in = compatible_layerversions)
+
+ search_maxids = map(lambda i: i[0], list(queryset.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id')))
+
+ queryset = queryset.filter(id__in=search_maxids).select_related('layer_version', 'layer_version__layer', 'layer_version__up_branch', 'layer_source')
+ return queryset
+
+
def schedule_build(self):
from bldcontrol.models import BuildRequest, BRTarget, BRLayer, BRVariable, BRBitbake
br = BuildRequest.objects.create(project = self)