[open-ils-commits] r9440 - trunk/Open-ILS/src/sql/Pg

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 23 09:02:24 EDT 2008


Author: miker
Date: 2008-04-23 08:23:10 -0400 (Wed, 23 Apr 2008)
New Revision: 9440

Modified:
   trunk/Open-ILS/src/sql/Pg/reporter-schema.sql
Log:
adding helper views for overdue, running and pending reports

Modified: trunk/Open-ILS/src/sql/Pg/reporter-schema.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/reporter-schema.sql	2008-04-23 12:22:42 UTC (rev 9439)
+++ trunk/Open-ILS/src/sql/Pg/reporter-schema.sql	2008-04-23 12:23:10 UTC (rev 9440)
@@ -213,5 +213,29 @@
         AND (stop_fines NOT IN ('LOST','CLAIMSRETURNED') OR stop_fines IS NULL)
         AND due_date < now();
 
+CREATE OR REPLACE VIEW reporter.overdue_reports AS
+ SELECT s.id, c.barcode AS runner_barcode, r.name, s.run_time, s.run_time - now() AS scheduled_wait_time
+   FROM reporter.schedule s
+   JOIN reporter.report r ON r.id = s.report
+   JOIN actor.usr u ON s.runner = u.id
+   JOIN actor.card c ON c.id = u.card
+  WHERE s.start_time IS NULL AND s.run_time < now();
+
+CREATE OR REPLACE VIEW reporter.pending_reports AS
+ SELECT s.id, c.barcode AS runner_barcode, r.name, s.run_time, s.run_time - now() AS scheduled_wait_time
+   FROM reporter.schedule s
+   JOIN reporter.report r ON r.id = s.report
+   JOIN actor.usr u ON s.runner = u.id
+   JOIN actor.card c ON c.id = u.card
+  WHERE s.start_time IS NULL;
+
+CREATE OR REPLACE VIEW reporter.currently_running AS
+ SELECT s.id, c.barcode AS runner_barcode, r.name, s.run_time, s.run_time - now() AS scheduled_wait_time
+   FROM reporter.schedule s
+   JOIN reporter.report r ON r.id = s.report
+   JOIN actor.usr u ON s.runner = u.id
+   JOIN actor.card c ON c.id = u.card
+  WHERE s.start_time IS NOT NULL AND s.complete_time IS NULL;
+
 COMMIT;
 



More information about the open-ils-commits mailing list