summaryrefslogtreecommitdiffstats
path: root/lib/toaster/orm
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-02-05 11:41:43 +0000
committerbrian avery <avery.brian@gmail.com>2016-02-08 12:48:14 -0800
commit4dde3d830cd38bbe306d83629dcb80da5fc9b027 (patch)
tree752afac53e87d0066ac1fe13def568810ac93ff6 /lib/toaster/orm
parente69b00532b011327bc2495a6fb52cfe98f0f897d (diff)
downloadbitbake-4dde3d830cd38bbe306d83629dcb80da5fc9b027.tar.gz
toaster: models add get_last_successful_built_target method
Add a convenience method to get the last successful build target for a CustomImageRecipe. Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com>
Diffstat (limited to 'lib/toaster/orm')
-rw-r--r--lib/toaster/orm/models.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 7f7b1f37e..9bfc00d66 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -1447,6 +1447,13 @@ class CustomImageRecipe(Recipe):
base_recipe = models.ForeignKey(Recipe, related_name='based_on_recipe')
project = models.ForeignKey(Project)
+ def get_last_successful_built_target(self):
+ """ Return the last successful built target object if one exists
+ otherwise return None """
+ return Target.objects.filter(Q(build__outcome=Build.SUCCEEDED) &
+ Q(build__project=self.project) &
+ Q(target=self.name)).last()
+
def get_all_packages(self):
"""Get the included packages and any appended packages"""
return CustomImagePackage.objects.filter((Q(recipe_appends=self) |