Bugzilla – Attachment 14715 Details for
Bug 6281
Bug in LCC sort routine
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bug 6281: introduce LC::CallNumber::LC for sorting LC call numbers
bug-6281-introduce-LCCallNumberLC-for-sorting-LC-c.patch (text/plain), 4.10 KB, created by
Kyle M Hall (khall)
on 2013-01-18 20:05:11 UTC
(
hide
)
Description:
bug 6281: introduce LC::CallNumber::LC for sorting LC call numbers
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-01-18 20:05:11 UTC
Size:
4.10 KB
patch
obsolete
>From 1393554e6b075926c1158a349218a335c1e3e064 Mon Sep 17 00:00:00 2001 >From: Galen Charlton <gmc@esilibrary.com> >Date: Fri, 17 Aug 2012 11:23:47 -0400 >Subject: [PATCH] bug 6281: introduce LC::CallNumber::LC for sorting LC call numbers > >This replaces the previous hand-coded normalizer. Because >LC::CallNumber::LC appears to reject strings that aren't valid >LC call numbers, significant changes to the test cases were >made as well -- however, the one that really counts is the >last one which verifies the sorting. > >To recalculate the call number sort key for each item, it is necessary >to run misc/maintenance/touch_all_items.pl > >To test, create item records with the following call numbers, setting >the classification sort to 'lccl: > >QC100 .U57 NO. 555 1986 >QC145 .A57 V.12 1980 >QC145.45 .H4 D65 1998 >QC995 .E29 1997 > >Next, make a report of them in the inventory tool. The items should be sorted >in the above order. > >Signed-off-by: Galen Charlton <gmc@esilibrary.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/ClassSortRoutine/LCC.pm | 19 ++++++------------- > t/ClassSortRoutine_LCC.t | 12 ++++++------ > 2 files changed, 12 insertions(+), 19 deletions(-) > >diff --git a/C4/ClassSortRoutine/LCC.pm b/C4/ClassSortRoutine/LCC.pm >index 6ec3846..f5f4a1c 100644 >--- a/C4/ClassSortRoutine/LCC.pm >+++ b/C4/ClassSortRoutine/LCC.pm >@@ -1,6 +1,7 @@ > package C4::ClassSortRoutine::LCC; > > # Copyright (C) 2007 LibLime >+# Copyright (C) 2012 Equinox Software, Inc. > # > # This file is part of Koha. > # >@@ -19,6 +20,7 @@ package C4::ClassSortRoutine::LCC; > > use strict; > use warnings; >+use Library::CallNumber::LC; > > use vars qw($VERSION); > >@@ -50,19 +52,10 @@ sub get_class_sort_key { > > $cn_class = '' unless defined $cn_class; > $cn_item = '' unless defined $cn_item; >- my $key = uc "$cn_class $cn_item"; >- $key =~ s/^\s+//; >- $key =~ s/\s+$//; >- $key =~ s/^[^\p{IsAlnum}\s.]//g; >- $key =~ s/^([A-Z]+)/$1 /; >- $key =~ s/(\.[A-Z])/ $1/g; >- # handle first digit group >- $key =~ s/(\d+)/sprintf("%-05.5d", $1)/xe; >- $key =~ s/\s+/_/g; >- $key =~ s/\./_/g; >- $key =~ s/__/_/g; >- $key =~ s/[^\p{IsAlnum}_]//g; >- >+ my $call_number = Library::CallNumber::LC->new(uc "$cn_class $cn_item"); >+ return '' unless defined $call_number; >+ my $key = $call_number->normalize(); >+ $key = '' unless defined $key; > return $key; > > } >diff --git a/t/ClassSortRoutine_LCC.t b/t/ClassSortRoutine_LCC.t >index 7454351..9ec37cf 100755 >--- a/t/ClassSortRoutine_LCC.t >+++ b/t/ClassSortRoutine_LCC.t >@@ -14,17 +14,17 @@ BEGIN { > > #Obvious cases > is(C4::ClassSortRoutine::LCC::get_class_sort_key(), "", "No arguments returns an empty string"); >-is(C4::ClassSortRoutine::LCC::get_class_sort_key('a','b'), "A_B", "Arguments 'a','b' return 'A_B'"); >+is(C4::ClassSortRoutine::LCC::get_class_sort_key('a','b'), "A B", "Arguments 'a','b' return 'A B'"); > > #spaces in arguements >-is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ','b'), "B_", "Arguments ' ','b' return 'B_'"); >-is(C4::ClassSortRoutine::LCC::get_class_sort_key('a',' '), "A_", "Arguments 'a',' ' return 'A_'"); >+is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ','b'), "B", "Arguments ' ','b' return 'B'"); >+is(C4::ClassSortRoutine::LCC::get_class_sort_key('a',' '), "A", "Arguments 'a',' ' return 'A'"); > is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ',' '), "", "Arguments ' ',' ' return ''"); > > #'funky cases' based on regex in code >-is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','b'), "_B", "Arguments '.','b' return '_B'"); >-is(C4::ClassSortRoutine::LCC::get_class_sort_key('....','........'), "_______", "Arguments '....','........' return '_______'"); >-is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','.'), "__", "Arguments '.','.' return '__'"); >+is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','b'), "", "Arguments '.','b' return ''"); >+is(C4::ClassSortRoutine::LCC::get_class_sort_key('....','........'), "", "Arguments '....','........' return ''"); >+is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','.'), "", "Arguments '.','.' return ''"); > > # list of example call numbers -- these > # are intentionally in the _reverse_ of >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6281
:
14478
|
14479
|
14480
|
14714
|
14715
|
14716
|
18527
|
18528
|
18529
|
18780
|
18781
|
18782