[open-ils-commits] [GIT] Evergreen ILS branch rel_2_3 updated. fa7b8347e9122cd785683599c6d4900763ddc88c
Evergreen Git
git at git.evergreen-ils.org
Tue Aug 20 10:52:59 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_3 has been updated
via fa7b8347e9122cd785683599c6d4900763ddc88c (commit)
via c024726cb5ac5f686b0253e09f010649b4696280 (commit)
from 85ca009c2bd0ba9e4580660ab3a6ec37d9a2e42d (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 fa7b8347e9122cd785683599c6d4900763ddc88c
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 958ee61..68255c5 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,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 c024726cb5ac5f686b0253e09f010649b4696280
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 7497878..5484357 100644
--- a/Open-ILS/src/sql/Pg/040.schema.asset.sql
+++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql
@@ -339,9 +339,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/;
@@ -350,7 +354,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;
@@ -359,6 +363,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