Skip to content

Commit

Permalink
Merge pull request #480 from vizor-games/master
Browse files Browse the repository at this point in the history
Support Scheduled and Cancelled registries
  • Loading branch information
cjlapao authored Feb 14, 2024
2 parents ab62651 + 51e2816 commit cad3b8b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rq_dashboard/templates/rq_dashboard/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
</div>
<select class="custom-select" id="select-registry" title="Registry name">
<option {% if registry_name == 'queued' %} selected {% endif %}>queued</option>
<option {% if registry_name == 'scheduled' %} selected {% endif %}>scheduled</option>
<option {% if registry_name == 'deferred' %} selected {% endif %}>deferred</option>
<option {% if registry_name == 'started' %} selected {% endif %}>started</option>
<option {% if registry_name == 'finished' %} selected {% endif %}>finished</option>
<option {% if registry_name == 'failed' %} selected {% endif %}>failed</option>
</select>
<option {% if registry_name == 'canceled' %} selected {% endif %}>canceled</option>
</select>
</div>

<p class="intro">
Expand Down
4 changes: 4 additions & 0 deletions rq_dashboard/templates/rq_dashboard/queues.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ <h1>Queues</h1>
<th>Queue</th>
<th class="narrow">Queued&nbsp;jobs</th>
<th class="narrow">Deferred&nbsp;jobs</th>
<th class="narrow">Scheduled&nbsp;jobs</th>
<th class="narrow">Started&nbsp;jobs</th>
<th class="narrow">Finished&nbsp;jobs</th>
<th class="narrow">Failed&nbsp;jobs</th>
<th class="narrow">Canceled&nbsp;jobs</th>
</tr>
</thead>
<tbody>
Expand All @@ -32,9 +34,11 @@ <h1>Queues</h1>
<td><%= d.name %></td>
<td class="narrow"> <a href="<%= d.queued_url %>"><%= d.count %></a></td>
<td class="narrow"> <a href="<%= d.deferred_url %>"><%= d.deferred_job_registry_count %></a></td>
<td class="narrow"> <a href="<%= d.scheduled_url %>"><%= d.scheduled_job_registry_count %></a></td>
<td class="narrow"> <a href="<%= d.started_url %>"><%= d.started_job_registry_count %></a></td>
<td class="narrow"> <a href="<%= d.finished_url %>"><%= d.finished_job_registry_count %></a></td>
<td class="failed"> <a href="<%= d.failed_url %>"><%= d.failed_job_registry_count %></a></td>
<td class="failed"> <a href="<%= d.canceled_url %>"><%= d.canceled_job_registry_count %></a></td>
</tr>
</script>

Expand Down
2 changes: 1 addition & 1 deletion rq_dashboard/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.6.7"
VERSION = "0.6.7.2"
33 changes: 33 additions & 0 deletions rq_dashboard/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
FailedJobRegistry,
FinishedJobRegistry,
StartedJobRegistry,
ScheduledJobRegistry,
CanceledJobRegistry,

)
from six import string_types

Expand Down Expand Up @@ -160,6 +163,24 @@ def serialize_queues(instance_number, queues):
per_page="8",
page="1",
),
canceled_job_registry_count=CanceledJobRegistry(q.name).count,
canceled_url=url_for(
".jobs_overview",
instance_number=instance_number,
queue_name=q.name,
registry_name="canceled",
per_page="8",
page="1",
),
scheduled_job_registry_count=ScheduledJobRegistry(q.name).count,
scheduled_url=url_for(
".jobs_overview",
instance_number=instance_number,
queue_name=q.name,
registry_name="scheduled",
per_page="8",
page="1",
),
)
for q in queues
]
Expand Down Expand Up @@ -232,6 +253,10 @@ def get_queue_registry_jobs_count(queue_name, registry_name, offset, per_page):
current_queue = StartedJobRegistry(queue_name)
elif registry_name == "finished":
current_queue = FinishedJobRegistry(queue_name)
elif registry_name == "scheduled":
current_queue = ScheduledJobRegistry(queue_name)
elif registry_name == "canceled":
current_queue = CanceledJobRegistry(queue_name)
else:
current_queue = queue
total_items = current_queue.count
Expand Down Expand Up @@ -410,6 +435,14 @@ def empty_queue(queue_name, registry_name):
ids = FinishedJobRegistry(queue_name).get_job_ids()
for id in ids:
delete_job_view(id)
elif registry_name == "canceled":
ids = CanceledJobRegistry(queue_name).get_job_ids()
for id in ids:
delete_job_view(id)
elif registry_name == "scheduled":
ids = ScheduledJobRegistry(queue_name).get_job_ids()
for id in ids:
delete_job_view(id)
return dict(status="OK")


Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "version": "0.6.7" }
{ "version": "0.6.7.2" }

0 comments on commit cad3b8b

Please sign in to comment.