[open-ils-commits] [GIT] Evergreen ILS branch master updated. b10df430e2afc97012bb4749b2b05226876db2db

Evergreen Git git at git.evergreen-ils.org
Tue Nov 15 16:14:52 EST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  b10df430e2afc97012bb4749b2b05226876db2db (commit)
       via  dbbb3a30c5f3fdfbd7f423e399d0e3707f4ae515 (commit)
       via  e6a0371eee20b373d2f09d27f0b44e712d481991 (commit)
      from  91201d1923a7498b95ab0adb7540a00636e413c3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b10df430e2afc97012bb4749b2b05226876db2db
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Nov 15 16:22:08 2011 -0500

    Stamped upgrade for full circ count view fix
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index db5e247..51ab5bc 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0648', :eg_version); -- phasefx/miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0649', :eg_version); -- dbwells/tsbere/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql b/Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql
new file mode 100644
index 0000000..2771e8e
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql
@@ -0,0 +1,21 @@
+-- Evergreen DB patch 0649.schema.fix_full_circ_count_view.sql
+--
+-- FIXME: insert description of change, if needed
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0649', :eg_version);
+
+-- FIXME: add/check SQL statements to perform the upgrade
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
+   FROM asset."copy" cp
+   LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
+   LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
+   LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
+  GROUP BY cp.id, c.circ_count;
+
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
deleted file mode 100644
index 2107adc..0000000
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
-   FROM asset."copy" cp
-   LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
-   LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
-   LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
-  GROUP BY cp.id, c.circ_count;

commit dbbb3a30c5f3fdfbd7f423e399d0e3707f4ae515
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Thu Sep 29 10:44:26 2011 -0400

    Use DISTINCT in counts to avoid dupes
    
    Otherwise you get:
    Legacy count + 2(normal count)(aged count)
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql
index 3643631..cb7eec5 100644
--- a/Open-ILS/src/sql/Pg/extend-reporter.sql
+++ b/Open-ILS/src/sql/Pg/extend-reporter.sql
@@ -26,7 +26,7 @@ CREATE TABLE extend_reporter.legacy_circ_count (
 );
 
 CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
+ SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
    FROM asset."copy" cp
    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
    LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
index eb558c3..2107adc 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
@@ -1,5 +1,5 @@
 CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
+ SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
    FROM asset."copy" cp
    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
    LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id

commit e6a0371eee20b373d2f09d27f0b44e712d481991
Author: Dan Wells <dbw2 at calvin.edu>
Date:   Thu Sep 29 09:23:49 2011 -0400

    Full Circ Count View Amplifies Legacy Circs
    
    The current extend_reported.full_circ_count sums the legacy circ count
    column, but this results in amplifying the count by the number of current
    circs in the system.  This commit adds the legacy count to the GROUP BY
    instead of summing it.
    
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql
index 6a13568..3643631 100644
--- a/Open-ILS/src/sql/Pg/extend-reporter.sql
+++ b/Open-ILS/src/sql/Pg/extend-reporter.sql
@@ -26,12 +26,12 @@ CREATE TABLE extend_reporter.legacy_circ_count (
 );
 
 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) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
+ SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
    FROM asset."copy" cp
    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
    LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
    LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
-  GROUP BY cp.id;
+  GROUP BY cp.id, c.circ_count;
 
 CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS
   SELECT DISTINCT ON (id) id, holding_update, update_type
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
new file mode 100644
index 0000000..eb558c3
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
@@ -0,0 +1,7 @@
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
+   FROM asset."copy" cp
+   LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
+   LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
+   LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
+  GROUP BY cp.id, c.circ_count;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/extend-reporter.sql            |    4 +-
 .../0649.schema.fix_full_circ_count_view.sql       |   21 ++++++++++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list