[Koha-patches] [PATCH] (bug #3393) take care of default rules in overdues

Joe Atzberger joe.atzberger at liblime.com
Wed Jul 8 18:03:29 CEST 2009


This doesn't make sense.

+    my $defaultbranches = $dbh->prepare("SELECT DISTINCT branchcode FROM
> overduerules WHERE delay1 IS NOT NULL AND branchcode = ''");
> +    $defaultbranches->execute();
> +    if($defaultbranches->rows > 0){
> +        foreach my $branch (keys %$availbranches){
> +            if(not grep{/^$branch$/} @branches){
> +                push @branches, $branch;
> +            }
> +        }
> +    }


You never fetch any data from $defaultbranches, so what you really are after
is SELECT COUNT (which you access via ->rows).

It doesn't make senes to me though, that basically you append all the
branches that didn't exist already in $rqoverduebranches.  In the end, that
is going to be the same as all the branchcodes in $availbranches, so you
don't need to build it piece by piece.

Then later in the loop, you have:

+    # We get default rules is there is no rule for this branch
> +    if($rqoverduerules->rows == 0){
> +        $rqoverduerules = $dbh->prepare("SELECT * FROM overduerules WHERE
> delay1 IS NOT NULL AND branchcode = '' ");
> +        $rqoverduerules->execute();
> +    }
>

The result of that is going to be the same each time.  There's no point
refetching it.  In fact, it is essentially the same query as
$defaultbranches, so it should be done only once, at the beginning of the
script.

-- 
Joe Atzberger
LibLime - Open Source Library Solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20090708/e05c995d/attachment-0002.htm>


More information about the Koha-patches mailing list