From be0056f66e925b3400dcd3fe40e4fa89ad1d52c7 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 3 Mar 2023 16:43:54 +0000 Subject: [PATCH] Bug 32613: (follow-up) Cache the tables This shouldn't be expected to change, except maybe after an upgrade, seems worth caching. To test: 1 - Apply patch 2 - Confirm the feature still works Signed-off-by: Tomas Cohen Arazi --- reports/guided_reports.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index fcd3cf2298..f4ed6cfdfc 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -1036,7 +1036,13 @@ sub header_cell_loop { #get a list of available tables for auto-complete sub get_tables { my $result = {}; - my $tables = C4::Reports::Guided->get_all_tables(); + my $cache = Koha::Caches->get_instance(); + my $tables = $cache->get_from_cache("Reports-SQL_tables-for-autocomplete"); + + return $tables + if $tables; + + $tables = C4::Reports::Guided->get_all_tables(); for my $table (@{$tables}) { my $sql = "SHOW COLUMNS FROM $table"; my $rows = C4::Context->dbh->selectall_arrayref($sql, { Slice => {} }); @@ -1044,6 +1050,7 @@ sub get_tables { push @{$result->{$table}}, $row->{Field}; } } + $cache->set_in_cache("Reports-SQL_tables-for-autocomplete",$result); return $result; } -- 2.39.5