=== modified file 'lava_scheduler_app/views.py'
@@ -8,6 +8,7 @@
from django.conf import settings
from django.core.urlresolvers import reverse
+from django.db.models import Count
from django.http import (
HttpResponse,
HttpResponseBadRequest,
@@ -166,15 +167,24 @@
return TestJob.objects.filter(health_check=True,
start_time__gte=(datetime.datetime.now() + relativedelta(hours=hr)))
+def _online_total():
+ ''' returns a tuple of (num_online, num_not_retired) '''
+ r = Device.objects.all().values('status').annotate(count=Count('status'))
+ offline = total = 0
+ for res in r:
+ if res['status'] in [Device.OFFLINE, Device.OFFLINING]:
+ offline += res['count']
+ if res['status'] != Device.RETIRED:
+ total += res['count']
+
+ return (total-offline,total)
+
@BreadCrumb("Scheduler", parent=lava_index)
def index(request):
return render_to_response(
"lava_scheduler_app/index.html",
{
- 'device_status': "%s/%s" % (
- Device.objects.filter(
- status__in=[Device.IDLE, Device.RUNNING]).count(),
- Device.objects.count()),
+ 'device_status': "%d/%d" % _online_total(),
'health_check_status': "%s/%s" % (
health_jobs_in_hr().filter(status=TestJob.COMPLETE).count(),
health_jobs_in_hr().count()),