From: miker Date: Thu, 24 Sep 2009 19:23:25 +0000 (+0000) Subject: Correcting reporting view definition with regard to ISBN and ISSN extraction X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=83f6c88996be5b8b4cb2b9c39869bac234824334;p=contrib%2FConifer.git Correcting reporting view definition with regard to ISBN and ISSN extraction git-svn-id: svn://svn.open-ils.org/ILS/trunk@14159 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 4b375c7df3..b94b121602 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0021'); -- mck9 +INSERT INTO config.upgrade_log (version) VALUES ('0022'); --miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/reporter-schema.sql b/Open-ILS/src/sql/Pg/reporter-schema.sql index aec6cd18ad..c7f787a6e2 100644 --- a/Open-ILS/src/sql/Pg/reporter-schema.sql +++ b/Open-ILS/src/sql/Pg/reporter-schema.sql @@ -158,8 +158,8 @@ SELECT r.id, FIRST(author.value) AS author, publisher.value AS publisher, SUBSTRING(pubdate.value FROM $$\d+$$) AS pubdate, - ARRAY_ACCUM( SUBSTRING(isbn.value FROM $$^\S+$$) ) AS isbn, - ARRAY_ACCUM( SUBSTRING(issn.value FROM $$^\S+$$) ) AS issn + ARRAY_ACCUM( DISTINCT SUBSTRING(isbn.value FROM $$^\S+$$) ) AS isbn, + ARRAY_ACCUM( DISTINCT SUBSTRING(issn.value FROM $$^\S+$$) ) AS issn FROM biblio.record_entry r LEFT JOIN metabib.full_rec title ON (r.id = title.record AND title.tag = '245' AND title.subfield = 'a') LEFT JOIN metabib.full_rec author ON (r.id = author.record AND author.tag IN ('100','110','111') AND author.subfield = 'a') diff --git a/Open-ILS/src/sql/Pg/upgrade/0022.schema.reporter-simple_record-materialized-view.sql b/Open-ILS/src/sql/Pg/upgrade/0022.schema.reporter-simple_record-materialized-view.sql new file mode 100644 index 0000000000..4f68acc701 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0022.schema.reporter-simple_record-materialized-view.sql @@ -0,0 +1,28 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0022'); --miker + +-- Need to recreate this view with DISTINCT calls to ARRAY_ACCUM, thus avoiding duplicated ISBN and ISSN values +CREATE OR REPLACE VIEW reporter.old_super_simple_record AS +SELECT r.id, + r.fingerprint, + r.quality, + r.tcn_source, + r.tcn_value, + title.value AS title, + FIRST(author.value) AS author, + publisher.value AS publisher, + SUBSTRING(pubdate.value FROM $$\d+$$) AS pubdate, + ARRAY_ACCUM( DISTINCT SUBSTRING(isbn.value FROM $$^\S+$$) ) AS isbn, + ARRAY_ACCUM( DISTINCT SUBSTRING(issn.value FROM $$^\S+$$) ) AS issn + FROM biblio.record_entry r + LEFT JOIN metabib.full_rec title ON (r.id = title.record AND title.tag = '245' AND title.subfield = 'a') + LEFT JOIN metabib.full_rec author ON (r.id = author.record AND author.tag IN ('100','110','111') AND author.subfield = 'a') + LEFT JOIN metabib.full_rec publisher ON (r.id = publisher.record AND publisher.tag = '260' AND publisher.subfield = 'b') + LEFT JOIN metabib.full_rec pubdate ON (r.id = pubdate.record AND pubdate.tag = '260' AND pubdate.subfield = 'c') + LEFT JOIN metabib.full_rec isbn ON (r.id = isbn.record AND isbn.tag IN ('024', '020') AND isbn.subfield IN ('a','z')) + LEFT JOIN metabib.full_rec issn ON (r.id = issn.record AND issn.tag = '022' AND issn.subfield = 'a') + GROUP BY 1,2,3,4,5,6,8,9; + +COMMIT; +