[open-ils-commits] r9439 - branches/rel_1_2/Open-ILS/src/sql/Pg

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 23 09:01:56 EDT 2008


Author: miker
Date: 2008-04-23 08:22:42 -0400 (Wed, 23 Apr 2008)
New Revision: 9439

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

Modified: branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql
===================================================================
--- branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql	2008-04-23 02:52:02 UTC (rev 9438)
+++ branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql	2008-04-23 12:22:42 UTC (rev 9439)
@@ -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