[OPEN-ILS-DEV] Parts sorting by month name

Remington Steed rjs7 at calvin.edu
Wed Feb 10 09:34:05 EST 2016


Josh,

This might not meet your needs, but some work has been done to allow manual ordering of parts.  See bug below.

"Parts ordering enhancement development proposal"
https://bugs.launchpad.net/evergreen/+bug/1169569

Remington

--
Remington Steed
Electronic Resources Specialist
Hekman Library, Calvin College
http://library.calvin.edu/

From: Open-ils-dev [mailto:open-ils-dev-bounces at list.georgialibraries.org] On Behalf Of Josh Stompro
Sent: Thursday, February 04, 2016 2:45 PM
To: open-ils-dev at list.georgialibraries.org
Subject: [OPEN-ILS-DEV] Parts sorting by month name

As I've been cleaning up the part labels I've noticed that there is a generated sorting field in the biblio.monograph_parts table, and I'm wondering how hard it would be to sort them by month based on the month name.

If I modified the trigger biblio.normalize_biblio_monograph_part_sortkey to add a prefix to the sortkey of the month index, would that do it?

JAN = 01jan
FEB = 02feb
MAR = 03mar

Would anyone else find this useful?  Or is this abusing parts too much from its intended use, since we are using it instead of serials for magazines?  Maybe this is also to English centric?

Something like this maybe?  I would probably include the full month names in this also.

CREATE OR REPLACE FUNCTION biblio.normalize_biblio_monograph_part_sortkey () RETURNS TRIGGER AS $$
BEGIN
    NEW.label_sortkey := REGEXP_REPLACE(
        evergreen.lpad_number_substrings(
            naco_normalize(NEW.label),
            '0',
            10
        ),
        E'\\s+',
        '',
        'g'
    );
    -- Sort by month name abreviation
    IF new.label ~* '^(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\M' THEN
        CASE
         WHEN new.label ~* '^JAN' THEN
          new.label_sortkey =: '01'||new.label_sortkey;
         WHEN new.label ~* '^FEB' THEN
          new.label_sortkey =: '02'||new.label_sortkey;
         WHEN new.label ~* '^MAR' THEN
          new.label_sortkey =: '03'||new.label_sortkey;
        END CASE;
    END IF;
    RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;

CREATE TRIGGER norm_sort_label BEFORE INSERT OR UPDATE ON biblio.monograph_part FOR EACH ROW EXECUTE PROCEDURE biblio.normalize_biblio_monograph_part_sortkey();


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libmail.georgialibraries.org/pipermail/open-ils-dev/attachments/20160210/c52acb0a/attachment.html>


More information about the Open-ils-dev mailing list