From 91fd6ddd7cfdd69d33b7742365336a5e42e050e9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 21 Dec 2021 10:49:56 -0300 Subject: [PATCH] Bug 29736: Restore searching Without this patch, the list will always display all clubs. To test: 1. Have two clubs, with enrollemnts: - Cthulhu fans - The Shadow Out of Time fans 2. Search for the letter c => FAIL: You get both results 3. Apply this patch 4. Repeat 2 => SUCCESS: Only Cthulhu is returned 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit 96012930ee78776af2a2c3e00aaf87a5ff231fac) Signed-off-by: Andrew Fuerste-Henry --- Koha/Clubs.pm | 8 +++----- reserve/request.pl | 7 ++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Koha/Clubs.pm b/Koha/Clubs.pm index 618326bc3a..4c3bccabce 100644 --- a/Koha/Clubs.pm +++ b/Koha/Clubs.pm @@ -88,7 +88,9 @@ sub get_enrollable { =head3 filter_out_empty - Remove clubs without current enrollments. + my $filtered_rs = $clubs_rs->filter_out_empty; + +Return a new I resultset, containing only clubs with current enrollments. =cut @@ -97,10 +99,6 @@ sub filter_out_empty { return $self->search( { -and => [ - [ - { name => { like => '%x%' } }, - { description => { like => '%x%' } }, - ], { 'club_enrollments.club_id' => { '!=' => undef } }, { 'club_enrollments.date_canceled' => undef }, ] diff --git a/reserve/request.pl b/reserve/request.pl index fd67560d4c..6079089135 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -145,7 +145,12 @@ if($findclub) { if( $club ) { $club_hold = $club->id; } else { - my @clubs = Koha::Clubs->search->filter_out_empty; + my @clubs = Koha::Clubs->search( + [ + { name => { like => '%' . $findclub . '%' } }, + { description => { like => '%' . $findclub . '%' } } + ] + )->filter_out_empty->as_list; if( scalar @clubs == 1 ) { $club_hold = $clubs[0]->id; -- 2.39.5