-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[4.4] Optimize scheduler running plugin #37120
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
[4.4] Optimize scheduler running plugin #37120
Conversation
Quy's suggestion Co-authored-by: Quy <[email protected]>
Quy's suggestion Co-authored-by: Quy <[email protected]>
Quy's suggestion Co-authored-by: Quy <[email protected]>
richard67
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me by review.
|
It was a deliberate decision to avoid any queries that bypass the model. That said I really like this, but could we instead add this as a method in the Scheduler model which could be then accessed through the Scheduler API class? That way we could avoid any localized logic in the plugin and also increase the useful API surface of the Scheduler which could be useful to other extensions. Thank you for working on this! |
|
This pull request has automatically rebased to 4.2-dev. |
|
Can you fix the conflict? |
administrator/components/com_scheduler/src/Model/TasksModel.php
Outdated
Show resolved
Hide resolved
administrator/components/com_scheduler/src/Model/TasksModel.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Allon Moritz <[email protected]>
Co-authored-by: Allon Moritz <[email protected]>
|
@Denitz - thank you for your work - what about ditsukes comment, moving the query to the model - would be nice. |
|
@MacJoom The query was moved to the model a year ago. |
|
Sorry i missed that one |
Summary of Changes
PlgSystemSchedulerunner::injectLazyJS()checks the presence of due tasks via weird loading of items list with order by title DESC using the admin model:Assuming that we are not loading the data but only counting the tasks which should be executed, we should not retrieve the full list of items, but only count them.
We have a second weird query to check if there are any locked tasks, the same invalid behavior occurs again:
These two queries can be optimized into single efficient query which loads the number of due tasks + the number of locked tasks:
Using backend list model is not efficient, better compose the query in the plugin.
The result of single query is checked and the plugin is not adding JS if we don't have due tasks OR we have locked tasks.
Testing Instructions
Test scheduled tasks
Actual result BEFORE applying this Pull Request
See two queries for
#__scheduler_taskstable.Expected result AFTER applying this Pull Request
See one query for
#__scheduler_taskstable.com_scheduler works as before.
Documentation Changes Required
No.