|
Lines 27-32
use List::MoreUtils qw/ any /;
Link Here
|
| 27 |
use LWP::Simple; |
27 |
use LWP::Simple; |
| 28 |
use XML::Simple; |
28 |
use XML::Simple; |
| 29 |
use Config; |
29 |
use Config; |
|
|
30 |
use Search::Elasticsearch; |
| 31 |
use Try::Tiny; |
| 30 |
|
32 |
|
| 31 |
use C4::Output; |
33 |
use C4::Output; |
| 32 |
use C4::Auth; |
34 |
use C4::Auth; |
|
Lines 40-47
use Koha::Patrons;
Link Here
|
| 40 |
use Koha::Caches; |
42 |
use Koha::Caches; |
| 41 |
use Koha::Config::SysPrefs; |
43 |
use Koha::Config::SysPrefs; |
| 42 |
use Koha::Illrequest::Config; |
44 |
use Koha::Illrequest::Config; |
|
|
45 |
use Koha::SearchEngine::Elasticsearch; |
| 46 |
|
| 43 |
use C4::Members::Statistics; |
47 |
use C4::Members::Statistics; |
| 44 |
|
48 |
|
|
|
49 |
|
| 45 |
#use Smart::Comments '####'; |
50 |
#use Smart::Comments '####'; |
| 46 |
|
51 |
|
| 47 |
my $query = new CGI; |
52 |
my $query = new CGI; |
|
Lines 292-297
if ( C4::Context->preference('ILLModule') ) {
Link Here
|
| 292 |
$template->param( warnILLConfiguration => $warnILLConfiguration ); |
297 |
$template->param( warnILLConfiguration => $warnILLConfiguration ); |
| 293 |
} |
298 |
} |
| 294 |
|
299 |
|
|
|
300 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
| 301 |
# Check ES configuration health and runtime status |
| 302 |
|
| 303 |
my $es_status; |
| 304 |
my $es_config_error; |
| 305 |
my $es_running = 1; |
| 306 |
|
| 307 |
my $es_conf; |
| 308 |
try { |
| 309 |
$es_conf = Koha::SearchEngine::Elasticsearch::_read_configuration(); |
| 310 |
} |
| 311 |
catch { |
| 312 |
if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) { |
| 313 |
$template->param( elasticsearch_fatal_config_error => $_->message ); |
| 314 |
$es_config_error = 1; |
| 315 |
} |
| 316 |
warn p($_); |
| 317 |
}; |
| 318 |
if ( !$es_config_error ) { |
| 319 |
|
| 320 |
my $biblios_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::BIBLIOS_INDEX; |
| 321 |
my $authorities_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::AUTHORITIES_INDEX; |
| 322 |
|
| 323 |
my @indexes = ($biblios_index_name, $authorities_index_name); |
| 324 |
# TODO: When new indexes get added, we could have other ways to |
| 325 |
# fetch the list of available indexes (e.g. plugins, etc) |
| 326 |
$es_status->{nodes} = $es_conf->{nodes}; |
| 327 |
my $es = Search::Elasticsearch->new({ nodes => $es_conf->{nodes} }); |
| 328 |
|
| 329 |
foreach my $index ( @indexes ) { |
| 330 |
my $count; |
| 331 |
try { |
| 332 |
$count = $es->indices->stats( index => $index ) |
| 333 |
->{_all}{primaries}{docs}{count}; |
| 334 |
} |
| 335 |
catch { |
| 336 |
if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) { |
| 337 |
push @{ $es_status->{errors} }, "Index not found ($index)"; |
| 338 |
$count = -1; |
| 339 |
} |
| 340 |
elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) { |
| 341 |
$es_running = 0; |
| 342 |
} |
| 343 |
else { |
| 344 |
# TODO: when time comes, we will cover more use cases |
| 345 |
die $_; |
| 346 |
} |
| 347 |
}; |
| 348 |
|
| 349 |
push @{ $es_status->{indexes} }, |
| 350 |
{ |
| 351 |
index_name => $index, |
| 352 |
count => $count |
| 353 |
}; |
| 354 |
} |
| 355 |
$es_status->{running} = $es_running; |
| 356 |
|
| 357 |
$template->param( elasticsearch_status => $es_status ); |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 295 |
# Sco Patron should not contain any other perms than circulate => self_checkout |
361 |
# Sco Patron should not contain any other perms than circulate => self_checkout |
| 296 |
if ( C4::Context->preference('WebBasedSelfCheck') |
362 |
if ( C4::Context->preference('WebBasedSelfCheck') |
| 297 |
and C4::Context->preference('AutoSelfCheckAllowed') |
363 |
and C4::Context->preference('AutoSelfCheckAllowed') |