diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-04-11 11:01:33 +1200 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-05-04 23:57:53 +1200 |
commit | 7606664eeb7a653db9c01c7dbd2bfc11e480f349 (patch) | |
tree | 191041b7d14b59b8a2aa45f5ca0a6f3659bf3eca /rrs/models.py | |
parent | da3bfff3a1d42d0db144565eaad3710df833d0b5 (diff) | |
download | openembedded-core-contrib-7606664eeb7a653db9c01c7dbd2bfc11e480f349.tar.gz |
rrs: link maintenance/upstream history to layerbranch
RecipeUpstreamHistory was not linked to the layer it was produced from,
which meant that it wasn't easy to query for a different maintenance
plan (i.e. a different layer) and thus the maintenance plan selection
on the recipe list didn't really work. Add a link field, populate it in
a migration and then make it required.
We had added a link earlier from RecipeMaintainerHistory to LayerBranch
but it was optional; for the same reasons we now populate it and make it
required.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'rrs/models.py')
-rw-r--r-- | rrs/models.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/rrs/models.py b/rrs/models.py index f2a65dd8bf..6650da984b 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -218,11 +218,11 @@ class RecipeMaintainerHistory(models.Model): date = models.DateTimeField(db_index=True) author = models.ForeignKey(Maintainer) sha1 = models.CharField(max_length=64, unique=True) - layerbranch = models.ForeignKey(LayerBranch, blank=True, null=True) + layerbranch = models.ForeignKey(LayerBranch) @staticmethod - def get_last(): - rmh_qry = RecipeMaintainerHistory.objects.filter().order_by('-date') + def get_last(layerbranch): + rmh_qry = RecipeMaintainerHistory.objects.filter(layerbranch=layerbranch).order_by('-date') if rmh_qry: return rmh_qry[0] @@ -230,14 +230,16 @@ class RecipeMaintainerHistory(models.Model): return None @staticmethod - def get_by_end_date(end_date): + def get_by_end_date(layerbranch, end_date): rmh_qry = RecipeMaintainerHistory.objects.filter( + layerbranch=layerbranch, date__lte = end_date).order_by('-date') if rmh_qry: return rmh_qry[0] rmh_qry = RecipeMaintainerHistory.objects.filter( + layerbranch=layerbranch ).order_by('date') if rmh_qry: return rmh_qry[0] @@ -267,12 +269,14 @@ class RecipeMaintainer(models.Model): self.maintainer.email) class RecipeUpstreamHistory(models.Model): + layerbranch = models.ForeignKey(LayerBranch) start_date = models.DateTimeField(db_index=True) end_date = models.DateTimeField(db_index=True) @staticmethod - def get_last_by_date_range(start, end): - history = RecipeUpstreamHistory.objects.filter(start_date__gte = start, + def get_last_by_date_range(layerbranch, start, end): + history = RecipeUpstreamHistory.objects.filter(layerbranch=layerbranch, + start_date__gte = start, start_date__lte = end).order_by('-start_date') if history: @@ -281,8 +285,9 @@ class RecipeUpstreamHistory(models.Model): return None @staticmethod - def get_first_by_date_range(start, end): - history = RecipeUpstreamHistory.objects.filter(start_date__gte = start, + def get_first_by_date_range(layerbranch, start, end): + history = RecipeUpstreamHistory.objects.filter(layerbranch=layerbranch, + start_date__gte = start, start_date__lte = end).order_by('start_date') if history: @@ -291,8 +296,8 @@ class RecipeUpstreamHistory(models.Model): return None @staticmethod - def get_last(): - history = RecipeUpstreamHistory.objects.filter().order_by('-start_date') + def get_last(layerbranch): + history = RecipeUpstreamHistory.objects.filter(layerbranch=layerbranch).order_by('-start_date') if history: return history[0] |