| | 216 | CREATE OR REPLACE VIEW reporter.overdue_reports AS |
| | 217 | SELECT s.id, c.barcode AS runner_barcode, r.name, s.run_time, s.run_time - now() AS scheduled_wait_time |
| | 218 | FROM reporter.schedule s |
| | 219 | JOIN reporter.report r ON r.id = s.report |
| | 220 | JOIN actor.usr u ON s.runner = u.id |
| | 221 | JOIN actor.card c ON c.id = u.card |
| | 222 | WHERE s.start_time IS NULL AND s.run_time < now(); |
| | 223 | |
| | 224 | CREATE OR REPLACE VIEW reporter.pending_reports AS |
| | 225 | SELECT s.id, c.barcode AS runner_barcode, r.name, s.run_time, s.run_time - now() AS scheduled_wait_time |
| | 226 | FROM reporter.schedule s |
| | 227 | JOIN reporter.report r ON r.id = s.report |
| | 228 | JOIN actor.usr u ON s.runner = u.id |
| | 229 | JOIN actor.card c ON c.id = u.card |
| | 230 | WHERE s.start_time IS NULL; |
| | 231 | |
| | 232 | CREATE OR REPLACE VIEW reporter.currently_running AS |
| | 233 | SELECT s.id, c.barcode AS runner_barcode, r.name, s.run_time, s.run_time - now() AS scheduled_wait_time |
| | 234 | FROM reporter.schedule s |
| | 235 | JOIN reporter.report r ON r.id = s.report |
| | 236 | JOIN actor.usr u ON s.runner = u.id |
| | 237 | JOIN actor.card c ON c.id = u.card |
| | 238 | WHERE s.start_time IS NOT NULL AND s.complete_time IS NULL; |
| | 239 | |