diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-09-12 11:16:30 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-09-12 11:16:30 +0200 |
commit | 7c5fb4bcc0f291bc0d9563545a2a7112084d5b26 (patch) | |
tree | 1edc9abf5f01a31bc0a1a95c5743da1b82b5995f /pharos-dashboard/dashboard/views.py | |
parent | e74c3f8f656a35bc8d482f997b4cea7515916026 (diff) |
Add utilization column to dev pod tab
JIRA: PHAROS-263
Change-Id: I25d5d4bf4ecc23febdc0c11eae3298ada9372e83
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'pharos-dashboard/dashboard/views.py')
-rw-r--r-- | pharos-dashboard/dashboard/views.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pharos-dashboard/dashboard/views.py b/pharos-dashboard/dashboard/views.py index 8954f6c..c34a7a5 100644 --- a/pharos-dashboard/dashboard/views.py +++ b/pharos-dashboard/dashboard/views.py @@ -40,10 +40,18 @@ class DevelopmentPodsView(TemplateView): dev_pods = [] for resource in resources: - dev_pod = (resource, None) + booking_utilization = resource.get_booking_utilization(weeks=4) + total = booking_utilization['booked_seconds'] + booking_utilization['available_seconds'] + try: + utilization_percentage = "%d%%" % (float(booking_utilization['booked_seconds']) / + total * 100) + except (ValueError, ZeroDivisionError): + return "" + + dev_pod = (resource, None, utilization_percentage) for booking in bookings: if booking.resource == resource: - dev_pod = (resource, booking) + dev_pod = (resource, booking, utilization_percentage) dev_pods.append(dev_pod) context = super(DevelopmentPodsView, self).get_context_data(**kwargs) |