fixing minor MR mapping bug
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Aug 2006 20:48:46 +0000 (20:48 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Aug 2006 20:48:46 +0000 (20:48 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5575 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm

index f273597..b263320 100644 (file)
@@ -185,17 +185,21 @@ sub rw_biblio_ingest_single_object {
                        { metarecord => $mr->id }
                )->gather(1);
 
-               my $best = $cstore->request(
-                       "open-ils.cstore.direct.biblio.record_entry.search",
-                       { id => [ map { $_->source } @$mrm ] },
-                       { 'select'      => { bre => [ qw/id quality/ ] },
-                         order_by      => { bre => "quality desc" },
-                         limit         => 1,
-                       }
-               )->gather(1);
+               if (@$mrm) {
+                       my $best = $cstore->request(
+                               "open-ils.cstore.direct.biblio.record_entry.search",
+                               { id => [ map { $_->source } @$mrm ] },
+                               { 'select'      => { bre => [ qw/id quality/ ] },
+                               order_by        => { bre => "quality desc" },
+                               limit           => 1,
+                               }
+                       )->gather(1);
 
-               if ($best->quality > $bib->quality) {
-                       $mr->master_record($best->id);
+                       if ($best->quality > $bib->quality) {
+                               $mr->master_record($best->id);
+                       } else {
+                               $mr->master_record($bib->id);
+                       }
                } else {
                        $mr->master_record($bib->id);
                }