Bugzilla – Attachment 115822 Details for
Bug 20212
Improve performance of acquisitions receive page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20212: Remove fix_query and assume ugliness
Bug-20212-Remove-fixquery-and-assume-ugliness.patch (text/plain), 5.65 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-01-26 14:12:39 UTC
(
hide
)
Description:
Bug 20212: Remove fix_query and assume ugliness
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-01-26 14:12:39 UTC
Size:
5.65 KB
patch
obsolete
>From c42ec1001c86a3fa4fe08f027057f2c38c502593 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 13 Jan 2021 11:53:15 +0100 >Subject: [PATCH] Bug 20212: Remove fix_query and assume ugliness > >It seems better to do things in an ugly way but simple than complicated. >This patch removes the fix_query method that deals with ean and isbn and >explicitly tell that it's a trick that must not be reused somewhere >else. >It should only be used by Koha internally and we should not advertised >it until it's ready. >This problem will have to be fixed properly when the GET /biblios route >will be implemented. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Acquisitions/Orders.pm | 91 +++-------------------------- > 1 file changed, 9 insertions(+), 82 deletions(-) > >diff --git a/Koha/REST/V1/Acquisitions/Orders.pm b/Koha/REST/V1/Acquisitions/Orders.pm >index 5419ce5c45d..4a704e7b1c0 100644 >--- a/Koha/REST/V1/Acquisitions/Orders.pm >+++ b/Koha/REST/V1/Acquisitions/Orders.pm >@@ -121,14 +121,15 @@ sub list { > $filtered_params //={}; > my @query_params_array; > my $query_params; >- if ( exists $reserved_params->{query} and defined $reserved_params->{query} ) { >- push @query_params_array, fix_query({ query => $reserved_params->{query} }); >- } >- if ( exists $reserved_params->{q} and defined $reserved_params->{q}) { >- push @query_params_array, fix_query({ query => decode_json($reserved_params->{q}) }); >- } >- if ( exists $reserved_params->{'x-koha-query'} and defined $reserved_params->{'x-koha-query'} ) { >- push @query_params_array, fix_query({ query => decode_json($reserved_params->{'x-koha-query'}) });; >+ >+ # FIXME The following lines are an ugly fix to deal with isbn and ean searches >+ # This must NOT be reused or extended >+ # Instead we need a better and global solution in a Koha::*Biblio method >+ for my $q ( qw( q query x-koha-query ) ) { >+ next unless $reserved_params->{$q}; >+ $reserved_params->{$q} =~ s|"biblio.isbn":|"biblio.biblioitem.isbn":|g; >+ $reserved_params->{$q} =~ s|"biblio.ean":|"biblio.biblioitem.ean":|g; >+ push @query_params_array, $reserved_params->{$q}; > } > > if(scalar(@query_params_array) > 1) { >@@ -292,78 +293,4 @@ sub delete { > }; > } > >-=head2 Internal methods >- >-=head3 fix_query >- >- my $query = fix_query($query); >- >-This method takes care of recursively fixing queries that should be done >-against biblioitems (instead if biblio as exposed on the API) >- >-=cut >- >-sub fix_query { >- my ($args) = @_; >- >- my $query = $args->{query}; >- my $biblioitem_fields = { >- 'biblio.age_restriction' => 'biblio.biblioitem.age_restriction', >- 'biblio.cn_class' => 'biblio.biblioitem.cn_class', >- 'biblio.cn_item' => 'biblio.biblioitem.cn_item', >- 'biblio.cn_sort' => 'biblio.biblioitem.cn_sort', >- 'biblio.cn_source' => 'biblio.biblioitem.cn_source', >- 'biblio.cn_suffix' => 'biblio.biblioitem.cn_suffix', >- 'biblio.collection_issn' => 'biblio.biblioitem.collection_issn', >- 'biblio.collection_title' => 'biblio.biblioitem.collection_title', >- 'biblio.collection_volume' => 'biblio.biblioitem.collection_volume', >- 'biblio.ean' => 'biblio.biblioitem.ean', >- 'biblio.edition_statement' => 'biblio.biblioitem.edition_statement', >- 'biblio.illustrations' => 'biblio.biblioitem.illustrations', >- 'biblio.isbn' => 'biblio.biblioitem.isbn', >- 'biblio.issn' => 'biblio.biblioitem.issn', >- 'biblio.item_type' => 'biblio.biblioitem.item_type', >- 'biblio.lc_control_number' => 'biblio.biblioitem.lc_control_number', >- 'biblio.material_size' => 'biblio.biblioitem.material_size', >- 'biblio.notes' => 'biblio.biblioitem.notes', >- 'biblio.number' => 'biblio.biblioitem.number', >- 'biblio.pages' => 'biblio.biblioitem.pages', >- 'biblio.publication_place' => 'biblio.biblioitem.publication_place', >- 'biblio.publication_year' => 'biblio.biblioitem.publication_year', >- 'biblio.publisher' => 'biblio.biblioitem.publisher', >- 'biblio.serial_total_issues' => 'biblio.biblioitem.serial_total_issues', >- 'biblio.url' => 'biblio.biblioitem.url', >- 'biblio.volume' => 'biblio.biblioitem.volume', >- 'biblio.volume_date' => 'biblio.biblioitem.volume_date', >- 'biblio.volume_description' => 'biblio.biblioitem.volume_description', >- }; >- >- if ( ref($query) eq 'HASH' ) { >- foreach my $key (keys %{$query}) { >- if ( exists $biblioitem_fields->{$key}) { >- my $subq = delete $query->{$key}; >- $query->{$biblioitem_fields->{$key}} = (ref($subq) eq 'HASH') >- ? fix_query({ query => $subq }) >- : $subq; >- } >- else { >- $query->{$key} = fix_query({ query => $query->{$key} }); >- } >- } >- } >- elsif ( ref($query) eq 'ARRAY' ) { >- my @accum; >- foreach my $item (@{$query}) { >- push @accum, fix_query({ query => $item }); >- } >- $query = \@accum; >- } >- else { # scalar >- $query = $biblioitem_fields->{$query} >- if exists $biblioitem_fields->{$query}; >- } >- >- return $query; >-} >- > 1; >-- >2.30.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 20212
:
97545
|
97546
|
97547
|
97629
|
97630
|
97633
|
97634
|
97635
|
97745
|
98226
|
98230
|
98241
|
99724
|
99725
|
99727
|
100142
|
100475
|
100476
|
100477
|
100478
|
100552
|
100553
|
100554
|
100555
|
100600
|
100601
|
100602
|
100603
|
100605
|
100606
|
100643
|
101320
|
103684
|
103685
|
103686
|
103687
|
103688
|
109861
|
109862
|
109863
|
109864
|
109866
|
109867
|
109868
|
109869
|
109870
|
109936
|
110229
|
110234
|
110478
|
110482
|
111568
|
111569
|
112310
|
112521
|
112522
|
112523
|
112524
|
112686
|
112695
|
112698
|
112699
|
112700
|
112702
|
112703
|
112704
|
112705
|
112706
|
112868
|
112882
|
112987
|
113278
|
113279
|
114607
|
114608
|
114609
|
114610
|
114611
|
114612
|
114613
|
114614
|
114615
|
114616
|
114617
|
114942
|
114953
|
114954
|
114956
|
114959
|
114963
|
115050
|
115056
|
115057
|
115060
|
115062
|
115107
|
115108
|
115109
|
115817
|
115818
|
115819
|
115820
|
115821
|
115822
|
115886
|
115887
|
115888
|
115889
|
115890
|
115891
|
115892
|
115893
|
115894
|
115895
|
115896
|
115897
|
115898
|
115899
|
115900
|
115901
|
115902
|
115903
|
115904
|
115905
|
115906
|
115920
|
115921
|
115940
|
115941
|
115943
|
115944
|
115945
|
115946
|
115947
|
115948
|
115949
|
115950
|
115951
|
115952
|
115953
|
115954
|
115955
|
115956
|
115957
|
115958
|
115959
|
115960
|
115961
|
115962
|
115963
|
115964
|
115965
|
116139