Browse Source

Bug 4833: (QA follow-up) Add budgetname to SearchSuggestion

This patch adds the budgetname to the return of SearchSuggestion
to improve performance.

To test:
- Same test plan as for the first patch
- Verify fund names show in the table
- Run t/db_dependent/Suggestions.t

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Katrin Fischer 5 years ago
committed by Nick Clemens
parent
commit
f2d886c3b3
  1. 4
      C4/Suggestions.pm
  2. 7
      acqui/newordersuggestion.pl
  3. 10
      t/db_dependent/Suggestions.t

4
C4/Suggestions.pm

@ -109,7 +109,8 @@ sub SearchSuggestion {
B2.branchname AS branchnamesuggestedby,
U2.email AS emailmanagedby,
U2.branchcode AS branchcodemanagedby,
U2.borrowernumber AS borrnummanagedby
U2.borrowernumber AS borrnummanagedby,
BU.budget_name AS budget_name
FROM suggestions
LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
LEFT JOIN branches AS B1 ON B1.branchcode=U1.branchcode
@ -117,6 +118,7 @@ sub SearchSuggestion {
LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber
LEFT JOIN branches AS B2 ON B2.branchcode=U2.branchcode
LEFT JOIN categories AS C2 ON C2.categorycode=U2.categorycode
LEFT JOIN aqbudgets AS BU ON budgetid=BU.budget_id
WHERE 1=1
}
);

7
acqui/newordersuggestion.pl

@ -138,13 +138,6 @@ my $suggestions_loop = SearchSuggestion(
}
);
foreach my $suggestion (@$suggestions_loop) {
if ($suggestion->{budgetid}){
my $bud = GetBudget( $suggestion->{budgetid} );
$suggestion->{budget_name} = $bud->{budget_name} if $bud;
}
}
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
$template->param(
suggestions_loop => $suggestions_loop,

10
t/db_dependent/Suggestions.t

@ -18,7 +18,7 @@
use Modern::Perl;
use DateTime::Duration;
use Test::More tests => 107;
use Test::More tests => 109;
use Test::Warn;
use t::lib::Mocks;
@ -26,7 +26,7 @@ use t::lib::TestBuilder;
use C4::Context;
use C4::Letters;
use C4::Budgets qw( AddBudgetPeriod AddBudget );
use C4::Budgets qw( AddBudgetPeriod AddBudget GetBudget );
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Libraries;
@ -369,6 +369,12 @@ $search_suggestion = SearchSuggestion({
});
is( @$search_suggestion, 3, 'SearchSuggestion (budgetid = "__ANY__") returns the correct number of suggestions' );
$search_suggestion = SearchSuggestion({ budgetid => $budget_id });
is( @$search_suggestion[0]->{budget_name}, GetBudget($budget_id)->{budget_name}, 'SearchSuggestion returns the correct budget name');
$search_suggestion = SearchSuggestion({ budgetid => "__NONE__" });
is( @$search_suggestion[0]->{budget_name}, undef, 'SearchSuggestion returns the correct budget name');
my $del_suggestion = {
title => 'my deleted title',
STATUS => 'CHECKED',

Loading…
Cancel
Save