CREATE OR REPLACE VIEW view__cron as
select
`taskName` AS `taskName`,
`timing` AS `timing`,
`status` AS `status`,
`lastRun` AS `lastRun`,
`started` AS `started`,
`timeout` AS `timeout`,
if((`taskName` = 'Monitor'),1,NULL) AS `isMonitor`,
if(((((unix_timestamp() - unix_timestamp(`started`)) / 60) > `timeout`) and (`status` = 'started')),1,NULL) AS `isGarbage`,
(case
when (`status` = 'started') then NULL
when (isnull(`lastRun`) or isnull(`status`) or isnull(`started`)) then 1
when (((unix_timestamp() - unix_timestamp(`started`)) / 60) >= `timing`) then 1
else NULL end) AS `isNeedToRun`
from `cron__jobs`
where (`active` = 'yes')