use distinct flag to force an aggregate workaround check
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 13 Nov 2008 21:21:29 +0000 (21:21 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 13 Nov 2008 21:21:29 +0000 (21:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11174 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 74382e9..ec5518b 100644 (file)
@@ -335,21 +335,18 @@ sub new_books_by_item {
 
        my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
 
-       my $o_search = { shortname => $ou };
-       if (!$ou || $ou eq '-') {
-               $o_search = { parent_ou => undef };
+       my @ou_ids;
+       if ($ou && $ou ne '-') {
+               my $orgs = $_storage->request(
+                       "open-ils.cstore.direct.actor.org_unit.search",
+                       { shortname => $ou },
+                       { flesh         => 10,
+                         flesh_fields  => { aou        => [qw/children/] }
+                       }
+               )->gather(1);
+               @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
        }
 
-       my $orgs = $_storage->request(
-               "open-ils.cstore.direct.actor.org_unit.search",
-               $o_search,
-               { flesh         => 3,
-                 flesh_fields  => { aou        => [qw/children/] }
-               }
-       )->gather(1);
-
-       my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
-
        $logger->debug("Searching for records with new copies at orgs [".join(',',@ou_ids)."], based on $ou");
        my $cns = $_storage->request(
                "open-ils.cstore.json_query.atomic",
@@ -363,7 +360,8 @@ sub new_books_by_item {
                        }, 
           order_by     => { acp => { create_date => { transform => 'max', direction => 'desc' } } },
                  limit         => $page_size,
-                 offset        => $offset
+                 offset        => $offset,
+          distinct  => 1
                }
        )->gather(1);