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

[3.x] Ability to see if a job is delayed #755

Merged
merged 10 commits into from
Feb 12, 2020
Merged

[3.x] Ability to see if a job is delayed #755

merged 10 commits into from
Feb 12, 2020

Conversation

Cannonb4ll
Copy link
Contributor

Sometimes I find myself in a situation where I want to see if a job was dispatched with a delay, this PR allows you to see if it is via a badge.

Examples:

img
img2

@driesvints
Copy link
Member

This looks okay but I would use a different color since blue is often associated with something that goes okay. Maybe the same yellow from the pause symbol? Also I'd just say "delayed" and not "delayed job". Maybe add that timestamp on hover?

@Cannonb4ll
Copy link
Contributor Author

Like this?

img

@driesvints
Copy link
Member

That looks better imo but let's see what others say :)

@Cannonb4ll
Copy link
Contributor Author

To sum up the colors, my personal favorite is the purple (primary) one.

img
img
img

@tomswinkels
Copy link
Contributor

@Cannonb4ll first, very nice!! I like this PR!

  • I think it is better to say Delayed (all in the list are jobs nothing else)
  • My favorite color the orange one
  • The suggestion of @driesvints with a hover on Delayed i think this is nice to have :)

@Cannonb4ll
Copy link
Contributor Author

Just committed the tooltip on hover:

img

For this I had to move popper.js import above the bootstrap import because the docs say so and jQuery import to the app.js in order for the tooltips to work.

Then I made a directive for the tooltip so each new record would also get the tooltip instance bound to its element. (Otherwise new records that show up dynamically will not have the tooltip anymore)

This also resulted that I removed the jQuery imports from the specific components. I also took the liberty to reduce JS size by importing the specific lodash package "take" in "Stacktrace.vue" as an example. We could do this with more components as I noticed the full lodash library is imported there which gives a lot of overhead of JS.

Let me know what you think!

@taylorotwell
Copy link
Member

It's weird to me to show this label for a job that is already finished processing. It only makes sense to me to see it while pending and even better if it shows a human readable thing like "Delayed for 10 minutes"

@tomswinkels
Copy link
Contributor

tomswinkels commented Feb 5, 2020

@taylorotwell i think you right. It is better to show the label when the delay is not passed. But where do you want to show the "Delayed for 10 minutes"? Only in the hover?

I think it is better to say "xx minutes" in the hover.

@Cannonb4ll
Copy link
Contributor Author

I agree with you @taylorotwell, which option do you prefer more?

Option 1:

img

Option 2:

img2

@tomswinkels
Copy link
Contributor

tomswinkels commented Feb 5, 2020

If you choose option 1 than remove the "Delayed for" in the hover. The label are say that it is a delayed job.

@taylorotwell
Copy link
Member

I'm fine with the tooltip... I think purple is a bit "in your face" for this informational stuff... I would have gone with a gray background or something.

@Cannonb4ll
Copy link
Contributor Author

We can grey these out, with badge-secondary:

img

@taylorotwell
Copy link
Member

Is this ready for review on your end?

@Cannonb4ll
Copy link
Contributor Author

Yes, it is. Not sure why the travis builds fail randomly though.

@Cannonb4ll
Copy link
Contributor Author

Sorry, quickly added 1 more small detail in the job detail screen, the Pushed At:

img

@@ -38,6 +38,8 @@ public function index(Request $request)
$jobs = $this->jobs->getRecent($request->query('starting_at', -1))->map(function ($job) {
$job->payload = json_decode($job->payload);

$job->delayed = strtotime(optional(unserialize($job->payload->data->command))->delay);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are unserializing the entire command to get this won't that re-issue the database queries needed to get the Eloquent models / collections required by the job?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taylorotwell Just tried, indeed it will introduce queries to be run whenever a model is type hinted into the job class, this will introduce reduced performance once there are jobs with a lot of models.

Is there a way to disable this magic once we call an unserialise on the payload?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I can think of off of the top of my head. It may be possible to extract the delay from the raw serialized string but I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to think and try some stuff out. Will get back on this, thanks, good find 👍

@Cannonb4ll
Copy link
Contributor Author

Cannonb4ll commented Feb 10, 2020

Ok, requesting a review again for this one.

What I did is remove the PHP way with unserialising as this was causing DB queries. Instead I used the phpunserialize JS package which was already included.

In order to do this I exported each TR row to its own component to make proper use of computed records. Now there are no DB queries anymore.

@laravel laravel deleted a comment from tomswinkels Feb 12, 2020
@taylorotwell taylorotwell merged commit 626546e into laravel:3.0 Feb 12, 2020
@fgilio
Copy link

fgilio commented Feb 18, 2020

Thank you for this!

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

Successfully merging this pull request may close these issues.

5 participants