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

Modify error color for Running tab when a job has 1 attempt #1518

Closed
Wittiest opened this issue Oct 14, 2024 · 4 comments · Fixed by #1525
Closed

Modify error color for Running tab when a job has 1 attempt #1518

Wittiest opened this issue Oct 14, 2024 · 4 comments · Fixed by #1525

Comments

@Wittiest
Copy link
Contributor

Problem

When a job is running and has 1 attempt, the badge with Attempts has an error color
Screenshot 2024-10-14 at 7 45 38 AM

Proposed Solution

For this tab when the attempt count is equal to 1, show a neutral gray color like the Succeeded tab

@bensheldon
Copy link
Owner

good catch, that makes sense to me to not have the error color. I imagine we'd have to thread down the context into that row which sounds messy, but probably worth it.

@bensheldon
Copy link
Owner

bensheldon commented Oct 16, 2024

oh good, it's much easier than that 👍🏻 This logic with the job state just needs to be a little more complex:

https://github.com/bensheldon/good_job/blob/ecf6df74d7aa8b5d480a6c50ec0e5ce84f90d01a/app/views/good_job/jobs/_table.erb#L87C1-L98C26

Is that a PR you'd be able to make?

@Wittiest
Copy link
Contributor Author

@bensheldon I am wondering if we have any guarantees from good_job that would make the implementation cleaner.

Specifically, will there always be data inside of recent_error or another field if a job has experienced a failed execution before? If so, we could simply change the logic to be:

<% if job.recent_error && job.status != :finished %>
# Show span

If there isn't something simple like that, this slightly-messy logic would work to do the following:

  • For :running jobs, only show error span if executions_count > 1
  • For :succeeded jobs, never show error span
  • For all other statuses, show error_span if executions_count > 0
<% show_error = (job.status == :running && job.executions_count > 1) || (![:finished, :running].include?(job.status) && job.executions_count > 0) %>
<% if show_error %>
   <%= tag.span job.executions_count, class: "badge rounded-pill bg-danger",
        data: {
          bs_toggle: "popover",
          bs_trigger: "hover focus click",
          bs_placement: "bottom",
          bs_content: job.recent_error,
        }
      %>
  <% else %>
    <span class="badge bg-secondary rounded-pill"><%= job.executions_count %></span>
  <% end %>

@bensheldon
Copy link
Owner

bensheldon commented Oct 17, 2024

Specifically, will there always be data inside of recent_error or another field if a job has experienced a failed execution before?

Good call! Yes, I think you're correct that this could more simply be (use job.error so it doesn't access any associated executions):

<% if job.error && job.status != :finished %>
# Show span

...also just fyi, I think recent_error is vestigial of GoodJob <v4 and should be deprecated and aliased to error. It used to be necessary because a Job was simply the most recent Execution but that's no longer the case and previous error from a job is not cleared when the job is re-executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants