Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
add details to running jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Feret committed Jul 17, 2020
1 parent 440e10d commit 2895710
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
6 changes: 5 additions & 1 deletion rq_mantis/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from flask import url_for
from redis import from_url, ConnectionError
from rq import get_failed_queue
from rq.job import Job
from werkzeug.exceptions import ServiceUnavailable

from rq_mantis.utils import WorkersChecker, get_queues_data
Expand Down Expand Up @@ -109,7 +110,10 @@ def queue_empty(name):
@app.route("/queue/<name>")
def queue_detail(name):
queue = get_queue_by_name(name)
running_jobs = rq.registry.StartedJobRegistry(name).get_job_ids()
running_jobs = {
Job.fetch(job_id)
for job_id in rq.registry.StartedJobRegistry(name).get_job_ids()
}

return render_template('queue.html', queue=queue, running_jobs=running_jobs)

Expand Down
28 changes: 4 additions & 24 deletions rq_mantis/templates/queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,12 @@ <h1>Enqueued</h1>
</div>
</div>
{% endfor %}
<h1>Running jobs</h1>
{% for job_id in running_jobs %}
<div class="queue-job-part">
<table class="table">
<tbody>
<tr>
<td>{{ job_id }}</td>
</tr>
</tbody>
</table>
</div>
{% endfor %}
{% if running_jobs %}
{% include 'running_jobs.html' %}
{% endif %}
</div>
{% elif running_jobs %}
<h1>Running jobs</h1>
{% for job_id in running_jobs %}
<div class="queue-job-part">
<table class="table">
<tbody>
<tr>
<td>{{ job_id }}</td>
</tr>
</tbody>
</table>
</div>
{% endfor %}
{% include 'running_jobs.html' %}
{% else %}
<p>No jobs in queue</p>
{% endif %}
Expand Down
29 changes: 29 additions & 0 deletions rq_mantis/templates/running_jobs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<h1>Running jobs</h1>
{% for job in running_jobs %}
<div class="queue-job-part">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th class="text-right">Status</th>
<th class="text-right">Name</th>
<th class="text-right">Args</th>
<th class="text-right">Kwargs</th>
<th class="text-right">Timeout</th>
<th class="text-right">Created at</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ job.id }}</td>
<td>{{ job.status }}</td>
<td>{{ job.func_name }}</td>
<td>{{ job.args }}</td>
<td>{{ job.kwargs }}</td>
<td>{{ job.timeout }}</td>
<td>{{ job.created_at|datetime }}</td>
</tr>
</tbody>
</table>
</div>
{% endfor %}

0 comments on commit 2895710

Please sign in to comment.