aboutsummaryrefslogtreecommitdiffstats
path: root/rrs/models.py
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-01-20 17:46:53 -0600
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:51 +1200
commit2a651efc9a6c4fb5f7618c9b2f9ce1e8690cebc0 (patch)
tree57d0ecd93d5f1b40f681df644b000928a010f651 /rrs/models.py
parenteb460ea90c3fc9c1c05e0ccf4a18e9ec5673d6fc (diff)
downloadopenembedded-core-contrib-2a651efc9a6c4fb5f7618c9b2f9ce1e8690cebc0.tar.gz
rrs: Add support for store RecipeUpstreamHistory
To provide statistics about RecipeUpstream information based on Milestones we need to store RecipeUpstreamHistory that contains when the update script was executed. rrs/admin.py: Add admin page for RecipeUpstreamHistory. rrs/models.py: Add model for RecipeUpstreamHistory with helper functions for get last and last by date range also add migration. Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Diffstat (limited to 'rrs/models.py')
-rw-r--r--rrs/models.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/rrs/models.py b/rrs/models.py
index e9dbcdcc7c..3f73e4a044 100644
--- a/rrs/models.py
+++ b/rrs/models.py
@@ -68,6 +68,32 @@ class RecipeMaintainer(models.Model):
return "%s: %s <%s>" % (self.recipe.pn, self.maintainer.name,
self.maintainer.email)
+class RecipeUpstreamHistory(models.Model):
+ start_date = models.DateTimeField()
+ end_date = models.DateTimeField()
+
+ @staticmethod
+ def get_last_by_date_range(start, end):
+ history = RecipeUpstreamHistory.objects.filter(start_date__gte = start,
+ start_date__lte = end).order_by('-id')
+
+ if history:
+ return history[0]
+ else:
+ return None
+
+ @staticmethod
+ def get_last():
+ history = RecipeUpstreamHistory.objects.filter().order_by('-id')
+
+ if history:
+ return history[0]
+ else:
+ return None
+
+ def __unicode__(self):
+ return '%s: %s' % (self.id, self.start_date)
+
class RecipeUpstream(models.Model):
RECIPE_UPSTREAM_STATUS_CHOICES = (
('N', 'Not updated'),
@@ -82,6 +108,7 @@ class RecipeUpstream(models.Model):
)
recipe = models.ForeignKey(Recipe)
+ history = models.ForeignKey(RecipeUpstreamHistory, null=True)
version = models.CharField(max_length=100, blank=True)
type = models.CharField(max_length=1, choices=RECIPE_UPSTREAM_TYPE_CHOICES, blank=True)
status = models.CharField(max_length=1, choices=RECIPE_UPSTREAM_STATUS_CHOICES, blank=True)