[Koha-bugs] [Bug 18212] Move SQL code from aqplan.pl administrative script into Koha directory perl modules

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Sun Oct 29 22:28:09 CET 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18212

--- Comment #22 from Josef Moravec <josef.moravec at gmail.com> ---
Comment on attachment 66570
  --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=66570
Bug 18212 - Moved all sql queries out aqplan.pl into Koha::Libraries.pm,
Koha::ItemType.pm, Koha::AuthorisedValue.pm files

Review of attachment 66570:
 --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=18212&attachment=66570)
-----------------------------------------------------------------

::: C4/Acquisition.pm
@@ +3055,5 @@
> +            });
> +    return $authvalues;
> +}
> +
> +

You don't need this, you use Koha::AuthorisedValues module directly

::: Koha/AuthorisedValue.pm
@@ +174,5 @@
> +         order_by => [qw/ lib /]
> +    });
> +    return @Getauthorised_values;
> +};
> +

You don't need this, you use Koha::AuthorisedValues module directly

@@ +187,5 @@
> +    Koha::AuthorisedValues->new()->search({
> +             category => { 'like','%a%'},
> +     });
> +    return @distinctauthorised_values;
> +};

You don't need this, you use Koha::AuthorisedValues module directly

::: Koha/ItemType.pm
@@ +116,5 @@
> +     my $sth   = $dbh->prepare($query);
> +     $sth->execute();
> +     return $sth;
> +}
> +

You don't need this, just use Koha::ItemTypes->search_with_localization

::: Koha/Libraries.pm
@@ +65,5 @@
> +    my $sth   = $dbh->prepare($query);
> +    $sth->execute();
> +    return $sth;
> +}
> +

Use Koha::Libraries->search for getting all libraries.

::: admin/aqplan.pl
@@ +110,4 @@
>  my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}->{'borrowernumber'}:'' );
>  
>  # build categories list
> +my @DistinctAuthValues = Koha::AuthorisedValue->GetDistinctCat();

should be something like:

my $acq_categories = Koha::AuthorisedValueCategories->search( { category => {
like => 'A%' } } );

@@ +116,5 @@
>  my @category_list;
>  
>  # a hash, to check that some hardcoded categories exist.
>  my %categories;
> +while ( my ($category) = each @DistinctAuthValues ) {

while ( my $category = $acq_categories->next ) {

@@ +191,4 @@
>  }
>  # ------------------------------------------------------------
>  if ( $authcat =~ m/^Asort/ ) {
> +    my @AuthValues = Koha::AuthorisedValue->GetAuthValues($authcat);

my $AuthValues = Koha::AuthorisedValues->search ( { category => $authcat } );

@@ +225,4 @@
>  }
>  
>  elsif ( $authcat eq 'ITEMTYPES' ) {
> +     my $sth = Koha::ItemType->GetItemTypes($dbh);

Koha::ItemTypes->search_with_localization

@@ +237,4 @@
>  
>  } elsif ( $authcat eq 'BRANCHES' ) {
>  
> +    my $sth = Koha::Libraries->GetBranches($dbh);

Koha::Libraries->search

@@ +249,3 @@
>  } elsif ($authcat) {
> +
> +    my $sth = Koha::AuthorisedValue->GetAuthValues($authcat,$dbh);

Koha::AuthorisedValues->search ( { category => $authcat } );

::: t/db_dependent/AuthorisedValues.t
@@ +100,5 @@
> +   {
> +        order_by => [qw/ lib /]
> +   });
> +};
> +

If you want to test some subroutine, you can't just redefine it in the test.
You need to use it from the place where it is defined... but you do not need
this sub routine at all, so no need to add this test

@@ +111,5 @@
> +   Koha::AuthorisedValues->new()->search({
> +      category => { 'like','%a%'},
> +   });
> +}
> +

If you want to test some subroutine, you can't just redefine it in the test.
You need to use it from the place where it is defined... but you do not need
this sub routine at all, so no need to add this test

::: t/db_dependent/Koha/ItemTypes.t
@@ +126,5 @@
> +    my $sth   = $dbh->prepare($query);
> +    $sth->execute();
> +    return $sth->rows;
> +}
> +

If you want to test some subroutine, you can't just redefine it in the test.
You need to use it from the place where it is defined... but you do not need
this sub routine at all, so no need to add this test

::: t/db_dependent/Koha/Libraries.t
@@ +92,5 @@
> +    my $sth   = $dbh->prepare($query);
> +    $sth->execute();
> +    return $sth->rows;
> +}
> +

If you want to test some subroutine, you can't just redefine it in the test.
You need to use it from the place where it is defined... but you do not need
this sub routine at all, so no need to add this test

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list