There have been several times that I have found that it would be useful if my todo list would react to another site. For example, if a business is temporary closed for a pandemic, I would like a todo item activated when it is open again. Another use case is moving the task of watering plants to a later date when it is likely to rain.
The method PRScheduledTaskExamples>>reportCheck:thenRetrieveLink:using:onPageAt:
implements this for Scheduled Tasks, steps are:
This code should be loaded into a newer version of Pharo 8, using older version (like from this problem) had image crashes retrieving https URLs.
Testing - Reading this page:
(PRScheduledTaskExamples newForKernelNamed: 'pier') reportCheck: [ :page | '*Aug*' match: page contents ] thenRetrieveLink: 'http://www.myborden.com/pier/john-c-borden/updates/todo-retrieves-url' using: [ :string | ('*temporary closed for a pandemic*' match: string) ifTrue: [ (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Use My Subscription to The Business') hideFromMenus: true. 'the business is still closed' ] ifFalse: [ (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Use My Subscription to The Business') hideFromMenus: false. (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Check the Business') deautomate. 'Open for business' ] ] onPageAt: '/Todo/Check the Business/report'.
(PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Check the Business') automate.
TaskScheduler allInstances anyOne
to ensure that this is runningTaskScheduler allInstances anyOne inspect
- The check business task should not be presentFetching the contents of a URL is quite time-consuming, and introduces additional dependencies on other systems. For tasks like monitoring another site, this is the intention so the check block can simply be: [ :ignore | true ]
and the check won't fail. Other examples like the plant watering example can check the state of the other tasks. Using the report page (like the testing example) allow it to implement a state-machine.
Code changed for this includes:
PRToDoTask>>deautomate
PRToDo>>tasks
to only return tasks which are not hidden from the menusJQAjax>>callback:
still had a call to #fixCallbackTemps
, this has been removed from Pharo 8