2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`expeditionRoute_Monitor`
|
|
|
|
AS SELECT `r`.`id` AS `routeFk`,
|
|
|
|
COUNT(DISTINCT IF(`e`.`id` IS NULL, `t`.`id`, NULL)) AS `tickets`,
|
|
|
|
COUNT(DISTINCT `e`.`id`) AS `expeditions`,
|
|
|
|
COUNT(DISTINCT `es`.`id`) AS `scanned`,
|
|
|
|
max(`e`.`created`) AS `lastPacked`,
|
2024-11-28 16:29:39 +00:00
|
|
|
`r`.`dated` AS `created`
|
2024-01-15 11:31:03 +00:00
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`vn`.`route` `r`
|
|
|
|
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`r`.`id` = `rm`.`routeFk`)
|
|
|
|
)
|
2024-05-27 07:07:23 +00:00
|
|
|
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
|
|
|
JOIN `vn`.`ticket` `t` ON(`t`.`routeFk` = `r`.`id`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`expedition` `e` ON(`e`.`ticketFk` = `t`.`id`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`expeditionScan` `es` ON(`es`.`expeditionFk` = `e`.`id`)
|
|
|
|
)
|
2024-11-28 16:29:39 +00:00
|
|
|
WHERE `r`.`dated` >= `util`.`yesterday`()
|
2024-01-15 11:31:03 +00:00
|
|
|
GROUP BY `r`.`id`
|