From d4b606f0e7b656138216644004ee6d18ff754b93 Mon Sep 17 00:00:00 2001 From: maxbr Date: Mon, 12 Sep 2016 11:16:30 +0200 Subject: Add utilization column to dev pod tab JIRA: PHAROS-263 Change-Id: I25d5d4bf4ecc23febdc0c11eae3298ada9372e83 Signed-off-by: maxbr --- tools/pharos-dashboard/dashboard/views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tools/pharos-dashboard/dashboard/views.py') diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py index 8954f6c3..c34a7a57 100644 --- a/tools/pharos-dashboard/dashboard/views.py +++ b/tools/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) -- cgit 1.2.3-korg