Print queue size of job pages
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Thu, 11 Nov 2010 15:03:33 +0000 (15:03 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Thu, 11 Nov 2010 15:03:33 +0000 (15:03 +0000)
Using human-friendly file/memory sizes

bin/djais/models.py
bin/djais/views.py
html_templates/job.html
html_templates/jobs.html

index c89d32aa7bf1eac2c77a59d97381f9cf369725c5..92468f520892f32beeb1f9d096c028d31cea9a89 100644 (file)
@@ -220,6 +220,11 @@ class Job(models.Model):
 
     def queue_rank(self):
         return Job.objects.filter(queue_time__lt=self.queue_time).filter(start_time__isnull=True).count() + 1
+
+    @staticmethod
+    def queue_size():
+        return Job.objects.filter(start_time__isnull=True).count()
+
     def process_time(self):
         dt = self.finish_time - self.start_time
         return nice_timedelta_str(dt)
index 03b8e48e7bc8b27572954ebbed5a708b6f9b36fc..e2d78b9aa993e1320e4ce29c308e136298834b70 100644 (file)
@@ -679,14 +679,17 @@ def jobs_index(request):
         jobs = request.user.job_set.all()
     else:
         jobs = request.user.job_set.filter(archive_time__isnull=True)
-    return render_to_response('jobs.html', {'jobs': jobs, 'archive': show_archive }, RequestContext(request))
+    
+    response = render_to_response('jobs.html', {'jobs': jobs, 'queue_size': Job.queue_size(), 'archive': show_archive }, RequestContext(request))
+    response['Refresh'] = 15
+    return response
 
 @http_authenticate(auth, 'ais')
 def job_detail(request, jobid):
     job = get_object_or_404(Job, id=jobid)
     if job.user != request.user:
         return HttpResponseForbidden('403 Forbidden')
-    response = render_to_response('job.html', {'job': job}, RequestContext(request))
+    response = render_to_response('job.html', {'job': job, 'queue_size': Job.queue_size()}, RequestContext(request))
     if not job.finish_time:
         response['Refresh'] = 5
     elif not job.archive_time:
index 2547915a89f5991cc3e58c6fe2cc744c3de9ceab..287b9c4faafd84aa1edc2510c2d9572dc20d1780 100644 (file)
@@ -14,7 +14,7 @@
 {% if job.finish_time %}
 Status: <b>Completed</b> at {{ job.finish_time|date:"Y-m-d H:i:s" }} UTC in {{ job.process_time }}<br>
 Result: {% if job.result %}<b>Error {{ job.result }}</b>{% else %}<b>Success</b><br>
-Result size: {{ job.get_sucess_size }} bytes<br>
+Result size: {{ job.get_sucess_size|filesizeformat }}<br>
 <a href="/job/{{ job.id }}/download" class=button>download</a>{% endif %}<br>
 {% else %}
     {% if job.start_time %}
@@ -24,13 +24,13 @@ Result size: {{ job.get_sucess_size }} bytes<br>
     CPU ID: {{ stats.processor }}<br>
     Nice: {{ stats.nice }}<br>
     State: {{ stats.state }}<br>
-    Virtual size: {{ stats.vsize }} bytes<br>
+    Virtual size: {{ stats.vsize|filesizeformat }}<br>
     User time: {{ stats.utime }} ticks<br>
     System time: {{ stats.stime }} ticks<br>
     {% endwith %}
     {% else %}
     Status: <b>Queued</b> since {{ job.queue_time }}.<br>
-    Position in jobs queue: {{ job.queue_rank }}<br>
+    Position in jobs queue: {{ job.queue_rank }} / {{ queue_size }}<br>
     {% endif %}
 {% endif %}
 
index e8f63901efad1f03e0fcb1c76112e75611d8b4fa..e5ac2885bddfa0a0c7dee2bce939c4ec46a8533e 100644 (file)
@@ -14,7 +14,7 @@
 {% endif %}
 <ul>
 {% for job in jobs %}
-<li>Job {{ job.id }}<br>
+<li><a href="{{job.id}}/">Job {{ job.id }}</a><br>
 <tt>{{ job.command }}</tt><br>
 {% if job.finish_time %}
 Status: <b>Completed</b> at {{ job.finish_time|date:"Y-m-d H:i:s" }} UTC in {{ job.process_time }}<br>
@@ -22,11 +22,11 @@ Result: {% if job.result %}<b>Error {{ job.result }}</b>{% else %}<b>Success</b>
 <a href="/job/{{ job.id }}/download" class=button>download</a>{% endif %}<br>
 {% else %}
     {% if job.start_time %}
-    Status:<b>Running</b> since {{ job.start_time }}.<br>
+    Status: <b>Running</b> since {{ job.start_time }}.<br>
     Pid: {{ job.pid }}<br>
     {% else %}
     Status: <b>Queued</b> since {{ job.queue_time }}.<br>
-    Position in jobs queue: {{ job.queue_rank }}<br>
+    Position in jobs queue: {{ job.queue_rank }} / {{ queue_size }}<br>
     {% endif %}
 {% endif %}