[Evergreen-dev] Struggling with title sorting
Ken Cox
kenstir at gmail.com
Sat Jan 28 22:07:03 EST 2023
I am struggling to sort lists by title in the mobile app. Can somebody
point me to the code where it happens, or explain how it's supposed to
happen?
I found code in misc_utils.tt2
<https://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/src/templates/opac/parts/misc_util.tt2;h=283bcb098c37f58337cffc5ec4a60c7403e154cd;hb=HEAD#l275>,
and read up on MARC 245 ind2 non-filing characters, hooray! I implemented
the logic and it doesn't match the OPAC, boo!
*Is this the right code in misc_utils.tt2
<https://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/src/templates/opac/parts/misc_util.tt2;h=283bcb098c37f58337cffc5ec4a60c7403e154cd;hb=HEAD#l275>
?*
275 # If the title has a "non-filing chaaracters"
276 # (to logically remove leading "The " for example)
277 # chop the title. Otherwise, chop until the first alphanumeric.
278 # BTW: Template Toolkit folds 1-element arrays to scalars!
279 title_node = xml.findnodes('//*[@tag="245"]');
280
281 args.nonfiling_characters = title_node.findvalue('@ind2');
282
283 IF (args.nonfiling_characters > 0);
284 args.sort_title =
args.sort_title.substr(args.nonfiling_characters);
285 ELSE;
286 args.sort_title =
args.sort_title.replace('^[^A-Z0-9]*','');
287 END;
*small example*
My public list
<https://catalog.cwmars.org/eg/opac/results?query=&qtype=keyword&fi%3Asearch_format=&locg=1&detail_record_view=0&bookbag=1952592&sort=titlesort&depth=0>
in
the OPAC sorted by Title looks like this:
1. "E" is for evidence
2. L'événement = Happening
3. "G" is for gumshoe
That looks right. Logging from the app show why this sort is wrong:
item 4692942 has 2 non-filing chars: "L' événement = : Happening" -> "
ÉVÉNEMENT = : HAPPENING"
item 3152814 has 0 non-filing chars: ""E" is for evidence" -> "E" IS FOR
EVIDENCE"
item 3176781 has 0 non-filing chars: ""G" is for gumshoe" -> "G" IS FOR
GUMSHOE"
The first item has a space after L' in the mvr record
<https://catalog.cwmars.org/osrf-gateway-v1?service=open-ils.search&method=open-ils.search.biblio.record.mods_slim.retrieve¶m=4692942&_ck=114&_sk=3-7-3>,
and so skipping 2 chars sorts on the space. Maybe this is an encoding
issue in the OSRF gateway?
Thanks for listening!
--
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.evergreen-ils.org/pipermail/evergreen-dev/attachments/20230128/c679f853/attachment.htm>
More information about the Evergreen-dev
mailing list