JIRA: PHAROS-263
Change-Id: I25d5d4bf4ecc23febdc0c11eae3298ada9372e83
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
dev_pods = []
for resource in resources:
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:
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)
dev_pods.append(dev_pod)
context = super(DevelopmentPodsView, self).get_context_data(**kwargs)
href={{ pod.slave.last_job_url }}>{{ pod.slave.last_job_name }}</a>
</th>
</tr>
href={{ pod.slave.last_job_url }}>{{ pod.slave.last_job_name }}</a>
</th>
</tr>
</tbody>
{% endblock table %}
</tbody>
{% endblock table %}
<th>Booked by</th>
<th>Booked until</th>
<th>Purpose</th>
<th>Booked by</th>
<th>Booked until</th>
<th>Purpose</th>
<th>Status</th>
<th></th>
<th>Status</th>
<th></th>
- {% for pod, booking in dev_pods %}
+ {% for pod, booking, utilization in dev_pods %}
<tr>
<th>
<a href={% url 'dashboard:resource' resource_id=pod.id %}>{{ pod.name }}</a>
<tr>
<th>
<a href={% url 'dashboard:resource' resource_id=pod.id %}>{{ pod.name }}</a>
<th>
{{ booking.purpose }}
</th>
<th>
{{ booking.purpose }}
</th>
+ <th>
+ {{ utilization }}
+ </th>
<th style="background-color:{{ pod.slave.status | jenkins_status_color }}">
{{ pod.slave.status }}
</th>
<th style="background-color:{{ pod.slave.status | jenkins_status_color }}">
{{ pod.slave.status }}
</th>
+ <th>
+ <a href="{% url 'dashboard:resource' resource_id=pod.id %}" class="btn btn-primary">
+ Info
+ </a>
+ </th>
</tr>
{% endfor %}
</tbody>
</tr>
{% endfor %}
</tbody>
$(document).ready(function () {
$('#table').DataTable({
columnDefs: [
$(document).ready(function () {
$('#table').DataTable({
columnDefs: [
- {type: 'status', targets: 5}
+ {type: 'status', targets: 6}