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 <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 96012930ee)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
(cherry picked from commit 91fd6ddd7c)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
Tomas Cohen Arazi 2021-12-21 10:49:56 -03:00 committed by Victor Grousset/tuxayo
parent 8691aae755
commit 24991fed04
2 changed files with 9 additions and 6 deletions

View File

@ -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<Koha::Clubs> 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 },
]

View File

@ -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;