[open-ils-commits] [GIT] Evergreen ILS branch rel_2_4 updated. dd990bb53c12f4dc8494052b47a41d11098e485a
Evergreen Git
git at git.evergreen-ils.org
Tue Aug 20 10:53:00 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, rel_2_4 has been updated
via dd990bb53c12f4dc8494052b47a41d11098e485a (commit)
via 6c9d99c81580c7cc060d60d51b7185208a1f6a8f (commit)
from 66a4d5552f93a809253ad5e06f2e13c234b9de0d (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 dd990bb53c12f4dc8494052b47a41d11098e485a
Author: Ben Shum <bshum at biblio.org>
Date: Tue Aug 20 10:50:43 2013 -0400
Stamping upgrade script for dewey sort fix
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index dc6f90d..61d9361 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 ('0818', :eg_version); -- senator/csharp
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0819', :eg_version); -- phasefx/bshum
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acn_dewey_normalizer.sql b/Open-ILS/src/sql/Pg/upgrade/0819.schema.acn_dewey_normalizer.sql
similarity index 91%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acn_dewey_normalizer.sql
rename to Open-ILS/src/sql/Pg/upgrade/0819.schema.acn_dewey_normalizer.sql
index fa4d501..049fd87 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acn_dewey_normalizer.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0819.schema.acn_dewey_normalizer.sql
@@ -1,11 +1,11 @@
--- Evergreen DB patch XXXX.schema.acn_dewey_normalizer.sql
+-- Evergreen DB patch 0819.schema.acn_dewey_normalizer.sql
--
-- Fixes Dewey call number sorting (per LP# 1150939)
--
BEGIN;
-- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0819', :eg_version);
CREATE OR REPLACE FUNCTION asset.label_normalizer_dewey(TEXT) RETURNS TEXT AS $func$
# Derived from the Koha C4::ClassSortRoutine::Dewey module
commit 6c9d99c81580c7cc060d60d51b7185208a1f6a8f
Author: Jason Etheridge <jason at esilibrary.com>
Date: Thu Mar 7 11:59:09 2013 -0500
LP#1150939 fix dewey sort
There's a bit in the code where it tries to pad the first digit group,
if it's the only digit group, but it assumed the digit group was the
first token.
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql
index ea10156..dea51fd 100644
--- a/Open-ILS/src/sql/Pg/040.schema.asset.sql
+++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql
@@ -340,9 +340,13 @@ CREATE OR REPLACE FUNCTION asset.label_normalizer_dewey(TEXT) RETURNS TEXT AS $f
$init =~ s/^([\p{IsAlpha}]+)/$1 /;
my @tokens = split /\.|\s+/, $init;
my $digit_group_count = 0;
+ my $first_digit_group_idx;
for (my $i = 0; $i <= $#tokens; $i++) {
if ($tokens[$i] =~ /^\d+$/) {
$digit_group_count++;
+ if ($digit_group_count == 1) {
+ $first_digit_group_idx = $i;
+ }
if (2 == $digit_group_count) {
$tokens[$i] = sprintf("%-15.15s", $tokens[$i]);
$tokens[$i] =~ tr/ /0/;
@@ -351,7 +355,7 @@ CREATE OR REPLACE FUNCTION asset.label_normalizer_dewey(TEXT) RETURNS TEXT AS $f
}
# Pad the first digit_group if there was only one
if (1 == $digit_group_count) {
- $tokens[0] .= '_000000000000000'
+ $tokens[$first_digit_group_idx] .= '_000000000000000'
}
my $key = join("_", @tokens);
$key =~ s/[^\p{IsAlnum}_]//g;
@@ -360,6 +364,7 @@ CREATE OR REPLACE FUNCTION asset.label_normalizer_dewey(TEXT) RETURNS TEXT AS $f
$func$ LANGUAGE PLPERLU;
+
CREATE OR REPLACE FUNCTION asset.label_normalizer_lc(TEXT) RETURNS TEXT AS $func$
use strict;
use warnings;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acn_dewey_normalizer.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acn_dewey_normalizer.sql
new file mode 100644
index 0000000..fa4d501
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acn_dewey_normalizer.sql
@@ -0,0 +1,52 @@
+-- Evergreen DB patch XXXX.schema.acn_dewey_normalizer.sql
+--
+-- Fixes Dewey call number sorting (per LP# 1150939)
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION asset.label_normalizer_dewey(TEXT) RETURNS TEXT AS $func$
+ # Derived from the Koha C4::ClassSortRoutine::Dewey module
+ # Copyright (C) 2007 LibLime
+ # Licensed under the GPL v2 or later
+
+ use strict;
+ use warnings;
+
+ my $init = uc(shift);
+ $init =~ s/^\s+//;
+ $init =~ s/\s+$//;
+ $init =~ s!/!!g;
+ $init =~ s/^([\p{IsAlpha}]+)/$1 /;
+ my @tokens = split /\.|\s+/, $init;
+ my $digit_group_count = 0;
+ my $first_digit_group_idx;
+ for (my $i = 0; $i <= $#tokens; $i++) {
+ if ($tokens[$i] =~ /^\d+$/) {
+ $digit_group_count++;
+ if ($digit_group_count == 1) {
+ $first_digit_group_idx = $i;
+ }
+ if (2 == $digit_group_count) {
+ $tokens[$i] = sprintf("%-15.15s", $tokens[$i]);
+ $tokens[$i] =~ tr/ /0/;
+ }
+ }
+ }
+ # Pad the first digit_group if there was only one
+ if (1 == $digit_group_count) {
+ $tokens[$first_digit_group_idx] .= '_000000000000000'
+ }
+ my $key = join("_", @tokens);
+ $key =~ s/[^\p{IsAlnum}_]//g;
+
+ return $key;
+
+$func$ LANGUAGE PLPERLU;
+
+-- regenerate sort keys for any dewey call numbers
+UPDATE asset.call_number SET id = id WHERE label_class = 2;
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/040.schema.asset.sql | 7 ++++++-
...ix.sql => 0819.schema.acn_dewey_normalizer.sql} | 12 ++++++++----
3 files changed, 15 insertions(+), 6 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0658.schema.acn_dewey_sort_fix.sql => 0819.schema.acn_dewey_normalizer.sql} (75%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list