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

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Dec 11 10:54:12 EST 2008


Author: miker
Date: 2008-12-11 10:54:10 -0500 (Thu, 11 Dec 2008)
New Revision: 11509

Modified:
   trunk/Open-ILS/src/sql/Pg/extend-reporter.sql
Log:
add OCLC "bibs with new/deleted holdings" reporting source

Modified: trunk/Open-ILS/src/sql/Pg/extend-reporter.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/extend-reporter.sql	2008-12-11 15:51:51 UTC (rev 11508)
+++ trunk/Open-ILS/src/sql/Pg/extend-reporter.sql	2008-12-11 15:54:10 UTC (rev 11509)
@@ -25,12 +25,35 @@
     circ_count  INT         NOT NULL DEFAULT 0
 );
 
-CREATE VIEW extend_reporter.full_circ_count AS
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
  SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) AS circ_count
    FROM asset."copy" cp
    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
    LEFT JOIN "action".all_circulation circ ON circ.target_copy = cp.id
   GROUP BY cp.id;
 
+CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS
+  SELECT id, LAST(holding_update) AS holding_update, update_type
+    FROM (SELECT  b.id,
+                  LAST(cp.create_date) AS holding_update,
+                  'add' AS update_type
+            FROM  biblio.record_entry b
+                  JOIN asset.call_number cn ON (cn.record = b.id)
+                  JOIN asset.copy cp ON (cp.call_number = cn.id)
+            WHERE NOT cp.deleted
+                  AND b.id > 0
+            GROUP BY b.id
+              UNION
+          SELECT  b.id,
+                  LAST(cp.edit_date) AS holding_update,
+                  'delete' AS update_type
+            FROM  biblio.record_entry b
+                  JOIN asset.call_number cn ON (cn.record = b.id)
+                  JOIN asset.copy cp ON (cp.call_number = cn.id)
+            WHERE cp.deleted
+                  AND b.id > 0
+            GROUP BY b.id)x
+    GROUP BY id, update_type;
+        
 COMMIT;
 



More information about the open-ils-commits mailing list