Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Scheduled and Cancelled registries #480

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" }
Loading