diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-25 12:10:55 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-25 12:10:55 +0200 |
commit | 2a634c9262e7f51a7802b69b9ba51641711f2ad4 (patch) | |
tree | 9243b3f065cc140f862be5bb6f7bc4f06905a309 /pharos-dashboard/jenkins | |
parent | e040d30e0a61077f2777beba5853103f327ec130 (diff) |
Add a Resource detail view
JIRA: RELENG-12
The resource page contains an utilization diagram, future bookings with
their jira tickets and a list of servers.
Change-Id: I2123ccbe96cde29a56af32b933ebbf6ba2668ed1
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'pharos-dashboard/jenkins')
-rw-r--r-- | pharos-dashboard/jenkins/models.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pharos-dashboard/jenkins/models.py b/pharos-dashboard/jenkins/models.py index 438a882..354887a 100644 --- a/pharos-dashboard/jenkins/models.py +++ b/pharos-dashboard/jenkins/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.utils import timezone class JenkinsSlave(models.Model): @@ -18,6 +19,18 @@ class JenkinsSlave(models.Model): last_job_installer = models.CharField(max_length=50, default='') last_job_result = models.CharField(max_length=30, default='') + def get_utilization(self, timedelta): + """ + Return a dictionary containing the count of idle, online and offline measurements in the time from + now-timedelta to now + """ + utilization = {'idle': 0, 'online': 0, 'offline': 0} + statistics = self.jenkinsstatistic_set.filter(timestamp__gte=timezone.now() - timedelta) + utilization['idle'] = statistics.filter(idle=True).count() + utilization['online'] = statistics.filter(online=True).count() + utilization['offline'] = statistics.filter(offline=True).count() + return utilization + class Meta: db_table = 'jenkins_slave' |