[Koha-patches] [PATCH] Update holdings sort to sort by items.enumchron if there's no serial record and the biblio.serial flag is set.

Ryan Higgins ryan.higgins at liblime.com
Fri Jul 25 19:59:28 CEST 2008


You're right, Joe, this was an error on my part.  I was hoping to allow for
the case of a library
with a large number of migrated item records that wished to begin using the
serials module
for future acquisitions.  This won't work, as the sort is by the publication
date, not by the caption,
which is stored in serialseq.  It would work, however, if the library
migrated their previous holdings
with enumchron prefixed by the date of publication in iso format.

All that aside, I'm not sure that your sort would return different results
than mine, but I'm not
so familiar with perl's sort internals.  It looks to me that item-by-item,
the sort function you've provided
would return the same value as just calling sort_either, or am I mistaken ?

It is not at all uncommon, though, for libraries to have a record with some
items attached to a serial issue
record and some not (those without a serial issue record would have all
serial publication data stored as the caption
in items.enumchron).

Ryan


On Fri, Jul 25, 2008 at 11:47 AM, Joe Atzberger <joe.atzberger at liblime.com>
wrote:

> Sorry, that got sent before I was done editing it.
>
> On Fri, Jul 25, 2008 at 11:39 AM, Joe Atzberger <joe.atzberger at liblime.com>
> wrote:
> Is there a problem when one item has publisheddate and another only has
> enumchron?  I still don't really understand enumchron, but I think we want a
> failover between two sets of comparisons, not two failovers of criteria.
> That is, unless I misunderstand and  publisheddate and enumchron really are
> interchangeable to that degree.  Can you confirm, Ryan?
>
> Otherwise I would propose something like :
> sub sort_pubdate {
>     my $key = 'publisheddate';
>     $b->{$key} and $a->{$key} or return 0;
>     $b->{$key} cmp $a->{$key};
> }
> sub sort_enum    {
>     my $key = 'enumchron';
>     $b->{$key} and $a->{$key} or return 0;
>     $b->{$key} cmp $a->{$key};
> }
> sub sort_either   {
>     ($b->{publisheddate} || $b->{enumchron})
>                     cmp
>     ($a->{publisheddate} || $a->{enumchron})   ;
> }
> ...
> return( sort {&sort_pubdate || &sort_enum || &sort_either } @results );
>
> --joe
>



-- 
Ryan Higgins

LibLime * Open-Source Solutions for Libraries
Featuring KohaZOOM ILS
888-564-2457 x704
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20080725/4b7f143b/attachment-0002.htm>


More information about the Koha-patches mailing list