SOC 2021: Cronjobs - Week 4
Note: This report comes later than expected owing to some issues on my end.
- 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 in
TagsField). 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 the
- 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.