Bugzilla – Attachment 115085 Details for
Bug 27380
Add option for taking a list parameter in reports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27380: Move get_prepped_report to object and use for svc/reports
Bug-27380-Move-getpreppedreport-to-object-and-use-.patch (text/plain), 3.28 KB, created by
Andrew Fuerste-Henry
on 2021-01-12 12:37:42 UTC
(
hide
)
Description:
Bug 27380: Move get_prepped_report to object and use for svc/reports
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2021-01-12 12:37:42 UTC
Size:
3.28 KB
patch
obsolete
>From f6719548b79b13e72e853afecfa04f4a3546a476 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 11 Jan 2021 20:07:39 +0000 >Subject: [PATCH] Bug 27380: Move get_prepped_report to object and use for > svc/reports > >This patch moves get_prepped_report to Koha:Report->prep_report >and adds some basic tests > >To test: >1 - Using the report created in last test, hit the report svc api like: >http://localhost:8081/cgi-bin/koha/svc/report?id=6¶m_name=One&sql_params=One¶m_name=Listy|list&sql_params=2345%0D%0A423%0D%0A3%0D%0A2%0D%0A12 >2 - Note the use of %0D%0A to separate list params >3 - Test with combinations with and without param_name specified >http://localhost:8081/cgi-bin/koha/svc/report?id=6&sql_params=5&sql_params=2345%0D%0A423%0D%0A3%0D%0A2%0D%0A12 > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > reports/guided_reports.pl | 45 --------------------------------------------- > 1 file changed, 45 deletions(-) > >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index b8cf9ce6f3..963e428004 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -1090,48 +1090,3 @@ sub create_non_existing_group_and_subgroup { > } > } > >-# pass $sth and sql_params, get back an executable query >-sub get_prepped_report { >- my ($sql, $param_names, $sql_params ) = @_; >- >- # First we split out the placeholders >- # This part of the code supports using [[ table.field | alias ]] in the >- # query and replaces it by table.field AS alias. Not sure why we would >- # need it if we can type the latter (which is simpler)? >- my @split = split /\[\[|\]\]/,$sql; >- my $headers; >- for(my $i=0;$i<$#split/2;$i++){ #The placeholders are always the odd elements of the array >- my ($type,$name) = split /\|/,$split[$i*2+1]; # We split them on '|' >- $headers->{$name} = $type; # Store as a lookup for the template >- $headers->{$name} =~ s/^\w*\.//; # strip the table name just as in $sth->{NAME} array >- $split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g; #Quote any special characters so we can replace the placeholders >- $name = C4::Context->dbh->quote($name); >- $sql =~ s/\[\[$split[$i*2+1]\]\]/$type AS $name/; # Remove placeholders from SQL >- } >- >- my %lookup; >- @lookup{@$param_names} = @$sql_params; >- @split = split /<<|>>/,$sql; >- my @tmpl_parameters; >- for(my $i=0;$i<$#split/2;$i++) { >- my $quoted = @$param_names ? $lookup{ $split[$i*2+1] } : @$sql_params[$i]; >- # if there are special regexp chars, we must \ them >- $split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g; >- if ($split[$i*2+1] =~ /\|\s*date\s*$/) { >- $quoted = output_pref({ dt => dt_from_string($quoted), dateformat => 'iso', dateonly => 1 }) if $quoted; >- } >- unless( $split[$i*2+1] =~ /\|\s*list\s*$/ && $quoted ){ >- $quoted = C4::Context->dbh->quote($quoted); >- } else { >- my @list = split /\n/, $quoted; >- my @quoted_list; >- foreach my $item ( @list ){ >- $item =~ s/\r//; >- push @quoted_list, C4::Context->dbh->quote($item); >- } >- $quoted="(".join(",",@quoted_list).")"; >- } >- $sql =~ s/<<$split[$i*2+1]>>/$quoted/; >- } >- return $sql,$headers; >-} >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27380
:
115044
|
115047
|
115048
|
115084
|
115085
|
116160
|
116161
|
116162
|
116163
|
116464
|
116465
|
116466
|
116818
|
116830
|
116908