SOC 2021: Cronjobs - Week 4
By Tushar Malik on 2021-08-02 03:16 in Summer 2021 CronJobs
Note: This report comes later than expected owing to some issues on my end.
Tasks Accomplished
- Complete the design of the Cronjob form: This was the central task accomplished this week, and much of the other changes tie in with this.
The major challenge was figuring out the right solution for how we want the form to behave and to what extend we should offer the scheduling options. This turned out to be more complex than expected, as while it's simple enough to take in an expression we wanted a simple, user-friendly way to take in rules and do the processing on the backend. In this process, I researched such forms offered by several other services and, together with my mentor, landed on the solution that best fits our project vision. While we still (yes, still) have some changes due on this end, the form now mostly functions as expected and its likely there won't be any breaking changes beyond this point. - Accommodate Plugin Param Injection: This really was the first task accomplished, but comes later in the report. In short, plugins can now inject fields into the params field group and expect them to be stored (and retrievable) from the params column in the Cronjobs table, where params are stored in a JSON encoded string form.
- Implement Custom Fields, Rule: This was one of the things I was looking forward to doing for some time now, as I was eager to explore the Joomla! form infrastructure (one can find it littered across several of my annotations). I implemented in total 3 custom Field classes (at least one of which should be axed soon).
We explored a bunch of options for the fields, in particular the advanced ruleset, including the Joomla Fancy Select layout (as seen inTagsField
). In the end, we have settled on the default multi-select field layout which seems to fit well for the purpose.
Following this, I implemented theExecutionRulesRule
custom Rule to validate the non-standard requirements of a Cronjob form submission (the chosen rule type must have corresponding form data). This still needs to be taken care of in JavaScript to block form submission on the user's end, but that's something I'll need help with considering the JDocs look out of date. - Update Database Structure: The DB now has a `execution_rules` column and a `cron_rules` column. The former houses the rules opted by the user as in the form, while the latter is built by processing execution rules into a crontab-like representation. This representation will be a superset of the standard Cron options, supporting a non-standard visits rule (under review right now)
- Miscellaneous Improvements:
- Improve Entry Validation in DisplayController: This set of changes features bugfixes to match behavior expected of the component in case the user jumps to the Cronjob view without due validation from CronjobController.
- Bugfix CronOptions: The
findOptions()
method was patched to handle null argument calls. - Add Caching to CronjobsHelper: To reduce overhead associated with repeated
getCronOptions()
calls and considering we don't expect the reponse to change during a request, the CronOptions object is now cached for the lifecycle of the request.
Links for the Repository and Relevant Pull Request(s)
- Repository: Joomla-Projects/soc21_website-cronjob
- Pull Request of the Week: PR#7
- Parent Pull Request: PR#4