Lines 30-38
use Koha::Cache;
Link Here
|
30 |
|
30 |
|
31 |
|
31 |
|
32 |
my $query = CGI->new(); |
32 |
my $query = CGI->new(); |
33 |
my $report = $query->param('id'); |
33 |
my $report_id = $query->param('id'); |
|
|
34 |
my $report_name = $query->param('name'); |
34 |
|
35 |
|
35 |
my $cache; |
36 |
my $cache; |
|
|
37 |
my $sql; |
38 |
my $type; |
39 |
my $notes; |
40 |
my $cache_expiry; |
41 |
my $public; |
36 |
|
42 |
|
37 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
43 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
38 |
{ |
44 |
{ |
Lines 45-52
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
45 |
); |
51 |
); |
46 |
|
52 |
|
47 |
if (Koha::Cache->is_cache_active) { |
53 |
if (Koha::Cache->is_cache_active) { |
|
|
54 |
if ($report_name) { # When retrieving by name, we have to hit the |
55 |
# database to get the ID before we can check |
56 |
# the cache. Yuck. |
57 |
( $sql, $type, $report_name, $notes, $cache_expiry, $public, $report_id ) = |
58 |
get_saved_report( { 'name' => $report_name } ); |
59 |
} |
60 |
|
48 |
$cache = Koha::Cache->new(); |
61 |
$cache = Koha::Cache->new(); |
49 |
my $page = $cache->get_from_cache("intranet:report:$report"); |
62 |
my $page = $cache->get_from_cache("intranet:report:$report_id"); |
50 |
if ($page) { |
63 |
if ($page) { |
51 |
print $query->header; |
64 |
print $query->header; |
52 |
print $page; |
65 |
print $page; |
Lines 57-64
if (Koha::Cache->is_cache_active) {
Link Here
|
57 |
print $query->header; |
70 |
print $query->header; |
58 |
|
71 |
|
59 |
# $public isnt used for intranet |
72 |
# $public isnt used for intranet |
60 |
my ( $sql, $type, $name, $notes, $cache_expiry, $public ) = |
73 |
unless ($sql) { |
61 |
get_saved_report($report); |
74 |
( $sql, $type, $report_name, $notes, $cache_expiry, $public, $report_id ) = |
|
|
75 |
get_saved_report($report_name ? { 'name' => $report_name } : { 'id' => $report_id } ); |
76 |
} |
62 |
my $offset = 0; |
77 |
my $offset = 0; |
63 |
my $limit = C4::Context->preference("SvcMaxReportRows") || 10; |
78 |
my $limit = C4::Context->preference("SvcMaxReportRows") || 10; |
64 |
my ( $sth, $errors ) = execute_query( $sql, $offset, $limit ); |
79 |
my ( $sth, $errors ) = execute_query( $sql, $offset, $limit ); |
Lines 67-71
my $json_text = to_json($lines);
Link Here
|
67 |
print $json_text; |
82 |
print $json_text; |
68 |
|
83 |
|
69 |
if (Koha::Cache->is_cache_active) { |
84 |
if (Koha::Cache->is_cache_active) { |
70 |
$cache->set_in_cache( "intranet:report:$report", $json_text, $cache_expiry ); |
85 |
$cache->set_in_cache( "intranet:report:$report_id", $json_text, $cache_expiry ); |
71 |
} |
86 |
} |
72 |
- |
|
|