[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch master updated. b8ec73d3f50e2c1b87ed8f112feab645fa69fd10

Evergreen Git git at git.evergreen-ils.org
Tue Oct 8 12:46:30 EDT 2013


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  b8ec73d3f50e2c1b87ed8f112feab645fa69fd10 (commit)
       via  ef7cefb61f5b73787243317a89a0df8d3b9ae645 (commit)
       via  c08953aa10258922e6d21dc30c28d47eb393204e (commit)
      from  9e8baba79e91a0a0369a46392ac44a8b6447ff4f (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 b8ec73d3f50e2c1b87ed8f112feab645fa69fd10
Author: Dan Wells <dbw2 at calvin.edu>
Date:   Tue Oct 8 12:45:12 2013 -0400

    Stamping upgrade 0839: alternative title index fix
    
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 0f946d4..28685a1 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,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 ('0838', :eg_version); -- senator/dbwells
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0839', :eg_version); -- eeevil/senator/dbwells
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql b/Open-ILS/src/sql/Pg/upgrade/0839.data.alternative-title-indexing.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
rename to Open-ILS/src/sql/Pg/upgrade/0839.data.alternative-title-indexing.sql
index 424dd00..7ce42c4 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0839.data.alternative-title-indexing.sql
@@ -1,7 +1,7 @@
 BEGIN;
 
 -- check whether patch can be applied
---SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0839', :eg_version);
 
 UPDATE config.metabib_field
 SET

commit ef7cefb61f5b73787243317a89a0df8d3b9ae645
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Wed Oct 2 11:52:25 2013 -0400

    Replace inappropriate browse reingest with ...
    
    ... attempt at reingest across browse/facets/search but limited to
    the alternative title index.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
index 2379513..424dd00 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
@@ -1,7 +1,7 @@
 BEGIN;
 
 -- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
 
 UPDATE config.metabib_field
 SET
@@ -13,9 +13,93 @@ WHERE
 
 COMMIT;
 
-\qecho This is a browse-only reingest of your bib records. It may take a while.
-\qecho You may cancel now without losing the effect of the rest of the
-\qecho upgrade script, and arrange the reingest later.
-\qecho .
-SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE)
-    FROM biblio.record_entry;
+-- The following function only appears in the upgrade script and not the
+-- baseline schema because it's not necessary in the latter (and it's a
+-- temporary function).  It just serves to do a hopefully cheaper, more
+-- focused reingest just to hit the alternative title index.
+
+-- This cribs from the guts of metabib.reingest_metabib_field_entries(),
+-- and if it actually is a timesaver over a full reingest, then at some
+-- point in the future it would be nice if we broke it out into a separate
+-- function to make things like this easier.
+
+CREATE OR REPLACE FUNCTION pg_temp.alternative_title_reingest( bib_id BIGINT ) RETURNS VOID AS $func$
+DECLARE
+    ind_data        metabib.field_entry_template%ROWTYPE;
+    mbe_row         metabib.browse_entry%ROWTYPE;
+    mbe_id          BIGINT;
+    b_skip_facet    BOOL := false;
+    b_skip_browse   BOOL := false;
+    b_skip_search   BOOL := false;
+    alt_title       INT;
+    value_prepped   TEXT;
+BEGIN
+    SELECT INTO alt_title id FROM config.metabib_field WHERE field_class = 'title' AND name = 'alternative';
+    FOR ind_data IN SELECT * FROM biblio.extract_metabib_field_entry( bib_id ) WHERE field = alt_title LOOP
+        IF ind_data.field < 0 THEN
+            ind_data.field = -1 * ind_data.field;
+        END IF;
+
+        IF ind_data.facet_field AND NOT b_skip_facet THEN
+            INSERT INTO metabib.facet_entry (field, source, value)
+                VALUES (ind_data.field, ind_data.source, ind_data.value);
+        END IF;
+
+        IF ind_data.browse_field AND NOT b_skip_browse THEN
+            -- A caveat about this SELECT: this should take care of replacing
+            -- old mbe rows when data changes, but not if normalization (by
+            -- which I mean specifically the output of
+            -- evergreen.oils_tsearch2()) changes.  It may or may not be
+            -- expensive to add a comparison of index_vector to index_vector
+            -- to the WHERE clause below.
+
+            value_prepped := metabib.browse_normalize(ind_data.value, ind_data.field);
+            SELECT INTO mbe_row * FROM metabib.browse_entry
+                WHERE value = value_prepped AND sort_value = ind_data.sort_value;
+
+            IF FOUND THEN
+                mbe_id := mbe_row.id;
+            ELSE
+                INSERT INTO metabib.browse_entry
+                    ( value, sort_value ) VALUES
+                    ( value_prepped, ind_data.sort_value );
+
+                mbe_id := CURRVAL('metabib.browse_entry_id_seq'::REGCLASS);
+            END IF;
+
+            INSERT INTO metabib.browse_entry_def_map (entry, def, source, authority)
+                VALUES (mbe_id, ind_data.field, ind_data.source, ind_data.authority);
+        END IF;
+
+        -- Avoid inserting duplicate rows, but retain granularity of being
+        -- able to search browse fields with "starts with" type operators
+        -- (for example, for titles of songs in music albums)
+        IF (ind_data.search_field OR ind_data.browse_field) AND NOT b_skip_search THEN
+            EXECUTE 'SELECT 1 FROM metabib.' || ind_data.field_class ||
+                '_field_entry WHERE field = $1 AND source = $2 AND value = $3'
+                INTO mbe_id USING ind_data.field, ind_data.source, ind_data.value;
+                -- RAISE NOTICE 'Search for an already matching row returned %', mbe_id;
+            IF mbe_id IS NULL THEN
+                EXECUTE $$
+                INSERT INTO metabib.$$ || ind_data.field_class || $$_field_entry (field, source, value)
+                    VALUES ($$ ||
+                        quote_literal(ind_data.field) || $$, $$ ||
+                        quote_literal(ind_data.source) || $$, $$ ||
+                        quote_literal(ind_data.value) ||
+                    $$);$$;
+            END IF;
+        END IF;
+
+    END LOOP;
+
+    IF NOT b_skip_search THEN
+        PERFORM metabib.update_combined_index_vectors(bib_id);
+    END IF;
+
+    RETURN;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+\qecho This is a partial reingest of your bib records. It may take a while.
+
+SELECT pg_temp.alternative_title_reingest(id) FROM biblio.record_entry WHERE NOT deleted;

commit c08953aa10258922e6d21dc30c28d47eb393204e
Author: Mike Rylander <mrylander at gmail.com>
Date:   Mon Sep 30 09:22:26 2013 -0400

    Capture all alternative titles
    
    With the addition of bib browse, the alternative title index definition
    was made to point at the 740 (ind2 != 2), which contains non-analytic
    alternative titles /and/ non-filing indicator info.  It used to capture
    both the 246 and (appropriate) 740's.  Allow either to match the XPath.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 0492203..1cc8f98 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -118,7 +118,7 @@ INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath,
 INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_sort_xpath ) VALUES 
     (3, 'title', 'translated', oils_i18n_gettext(3, 'Translated Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='translated-nfi')]$$, '//@xlink:href', $$*[local-name() != "nonSort"]$$ );
 INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_sort_xpath ) VALUES 
-    (4, 'title', 'alternative', oils_i18n_gettext(4, 'Alternate Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='alternative-nfi')]$$, '//@xlink:href', $$*[local-name() != "nonSort"]$$ );
+    (4, 'title', 'alternative', oils_i18n_gettext(4, 'Alternate Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and starts-with(@type,'alternative')]$$, '//@xlink:href', $$*[local-name() != "nonSort"]$$ );
 INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_sort_xpath ) VALUES 
     (5, 'title', 'uniform', oils_i18n_gettext(5, 'Uniform Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform-nfi')]$$, '//@xlink:href', $$*[local-name() != "nonSort"]$$ );
 INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_field, browse_sort_xpath ) VALUES 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
new file mode 100644
index 0000000..2379513
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.alternative-title-indexing.sql
@@ -0,0 +1,21 @@
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+UPDATE config.metabib_field
+SET
+    xpath = $$//mods32:mods/mods32:titleInfo[mods32:title and starts-with(@type,'alternative')]$$,
+    browse_sort_xpath = $$*[local-name() != "nonSort"]$$,
+    browse_xpath = NULL
+WHERE
+    field_class = 'title' AND name = 'alternative' ;
+
+COMMIT;
+
+\qecho This is a browse-only reingest of your bib records. It may take a while.
+\qecho You may cancel now without losing the effect of the rest of the
+\qecho upgrade script, and arrange the reingest later.
+\qecho .
+SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE)
+    FROM biblio.record_entry;

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |    2 +-
 .../0839.data.alternative-title-indexing.sql       |  105 ++++++++++++++++++++
 3 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0839.data.alternative-title-indexing.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list