SELECT CAST(CONCAT(CAST(DATE_FORMAT(NOW(),'%Y-%m-%d')AS CHAR),':',hour_value,':',Min_value) AS DATETIME) AS time
,COUNT(*) AS value
FROM
(
SELECT dag_id
,SUBSTRING_INDEX(SUBSTRING_INDEX(Hour_value,',',nt.n),',',-1) AS hour_value
,Min_value
,schedule_interval
FROM
(
SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL
SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL
SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL SELECT 24
)AS nt
INNER JOIN
(
SELECT dag_id
,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE (schedule_interval,'"',''),' ',2),' ',-1) = '*'
THEN '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23'
ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE (schedule_interval,'"',''),' ',2),' ',-1) END
AS Hour_value
,SUBSTRING_INDEX(REPLACE (schedule_interval,'"',''),' ',1)AS Min_value
,schedule_interval
FROM dag
WHERE is_active = 1 AND schedule_interval NOT IN ('"@once"') AND is_paused = 0
AND schedule_interval LIKE '%"'
AND schedule_interval LIKE '%* * *"'
)AS ot
ON CHAR_LENGTH(ot.Hour_value) -CHAR_LENGTH(REPLACE(ot.Hour_value, ',', ''))>=nt.n-1
)AS T1
GROUP BY CAST(CONCAT(CAST(DATE_FORMAT(NOW(),'%Y-%m-%d')AS CHAR),':',hour_value,':',Min_value) AS DATETIME)
ORDER BY CAST(CONCAT(CAST(DATE_FORMAT(NOW(),'%Y-%m-%d')AS CHAR),':',hour_value,':',Min_value) AS DATETIME) ASC
|
cs |