From b1596b71ce7584185a2a757f03b824e0034c980b Mon Sep 17 00:00:00 2001 From: Andrey Nehaychik Date: Mon, 22 Apr 2024 13:37:20 +0200 Subject: [PATCH] Fix dates and result displaying --- rq_dashboard/templates/rq_dashboard/job.html | 6 ------ rq_dashboard/templates/rq_dashboard/scripts/job.js | 9 +++++++-- rq_dashboard/web.py | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/rq_dashboard/templates/rq_dashboard/job.html b/rq_dashboard/templates/rq_dashboard/job.html index e1eec6ba..053241f2 100644 --- a/rq_dashboard/templates/rq_dashboard/job.html +++ b/rq_dashboard/templates/rq_dashboard/job.html @@ -23,24 +23,18 @@

Job ID: {{ id }}

Description:
<%= d.description %>

Origin queue:
<%= d.origin %>

Status:
<%= d.status %>

- <% if (d.result) { %>

Result:
<%= d.result %>

- <% } %>

Created at:
<%= d.created_at %>

Enqueued at:
<%= d.enqueued_at %>

- <% if (d.exc_info) { %>

Ended at:
<%= d.ended_at %>

- <% } %>
- <% if (d.exc_info) { %>
<%= d.exc_info %>
- <% } %> diff --git a/rq_dashboard/templates/rq_dashboard/scripts/job.js b/rq_dashboard/templates/rq_dashboard/scripts/job.js index a38f27ed..9941a046 100644 --- a/rq_dashboard/templates/rq_dashboard/scripts/job.js +++ b/rq_dashboard/templates/rq_dashboard/scripts/job.js @@ -20,12 +20,17 @@ $job_data.empty(); job.created_at = toRelative(Date.create(job.created_at)) + ' / ' + toShort(Date.create(job.created_at)); - if (job.enqueued_at !== undefined) { + if (job.enqueued_at !== null) { job.enqueued_at = toRelative(Date.create(job.enqueued_at)) + ' / ' + toShort(Date.create(job.enqueued_at)); + } else { + job.enqueued_at = '-' } - if (job.ended_at !== undefined) { + if (job.ended_at !== null) { job.ended_at = toRelative(Date.create(job.ended_at)) + ' / ' + toShort(Date.create(job.ended_at)); + } else { + job.ended_at = '-' } + if (job.status === "failed") { $("#requeue-job-btn").show() } diff --git a/rq_dashboard/web.py b/rq_dashboard/web.py index c30df68a..e2fe2e60 100644 --- a/rq_dashboard/web.py +++ b/rq_dashboard/web.py @@ -584,7 +584,7 @@ def job_info(instance_number, job_id): ended_at=serialize_date(job.ended_at), origin=job.origin, status=job.get_status(), - result=job._result, + result=job.return_value(), exc_info=str(job.exc_info) if job.exc_info else None, description=job.description, )