|
Line 0
Link Here
|
| 0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
use Koha::Installer::Output qw(say_warning say_success say_info); |
| 3 |
use Koha::SearchEngine::Elasticsearch::Indexer; |
| 4 |
|
| 5 |
return { |
| 6 |
bug_number => "40658", |
| 7 |
description => "Ensure local-number is sortable", |
| 8 |
up => sub { |
| 9 |
my ($args) = @_; |
| 10 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 11 |
|
| 12 |
# Do you stuffs here |
| 13 |
my ( $local_number_map_id, $local_number_sortable ) = $dbh->selectrow_array( |
| 14 |
q| |
| 15 |
SELECT search_marc_map_id,sort FROM search_field |
| 16 |
JOIN search_marc_to_field ON search_field.id = search_marc_to_field.search_field_id |
| 17 |
JOIN search_marc_map ON search_marc_to_field.search_marc_map_id = search_marc_map.id |
| 18 |
WHERE search_field.name='local-number' AND index_name = 'biblios' AND marc_type='marc21'; |
| 19 |
| |
| 20 |
); |
| 21 |
|
| 22 |
if ( defined $local_number_map_id && $local_number_sortable == 0 ) { |
| 23 |
$dbh->do( |
| 24 |
q{ |
| 25 |
UPDATE search_marc_to_field |
| 26 |
SET sort = 1 |
| 27 |
WHERE search_marc_map_id = ? |
| 28 |
}, undef, $local_number_map_id |
| 29 |
); |
| 30 |
|
| 31 |
my $index_name = $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX; |
| 32 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } ); |
| 33 |
$indexer->update_mappings(); |
| 34 |
say $out "Updated ES mappings to make local-number sortable"; |
| 35 |
} elsif ( !defined $local_number_map_id ) { |
| 36 |
say_warning( $out, "No mapping defined for local-number" ); |
| 37 |
} else { |
| 38 |
say_info( $out, "local-number already sortable" ); |
| 39 |
} |
| 40 |
}, |
| 41 |
}; |