From db4e82255cc44c5680fd1840614f2d930625c266 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 11 Dec 2008 19:27:13 +0000 Subject: [PATCH] logic fix to new bibs-by-holdings-change view git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_3@11529 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/extend-reporter.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql index e2b2ed0447..2de8e5ef66 100644 --- a/Open-ILS/src/sql/Pg/extend-reporter.sql +++ b/Open-ILS/src/sql/Pg/extend-reporter.sql @@ -33,6 +33,28 @@ CREATE VIEW extend_reporter.full_circ_count AS GROUP BY cp.id; CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS + SELECT DISTINCT ON (id) id, 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 + ORDER BY id, holding_update; + SELECT id, LAST(holding_update) AS holding_update, update_type FROM (SELECT b.id, LAST(cp.create_date) AS holding_update, -- 2.11.0