Bugzilla – Attachment 56872 Details for
Bug 17500
Use Elasticsearch to search for patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17500: implement order by
Bug-17500-implement-order-by.patch (text/plain), 2.94 KB, created by
Jonathan Druart
on 2016-10-26 13:23:19 UTC
(
hide
)
Description:
Bug 17500: implement order by
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-10-26 13:23:19 UTC
Size:
2.94 KB
patch
obsolete
>From b9999964dd95278811cdf9cf16652d64b19bcd35 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 26 Oct 2016 14:44:45 +0200 >Subject: [PATCH] Bug 17500: implement order by > >--- > C4/Utils/DataTables.pm | 22 ++++++++++++++++------ > C4/Utils/DataTables/Members.pm | 4 +++- > C4/Utils/DataTables/VirtualShelves.pm | 2 +- > 3 files changed, 20 insertions(+), 8 deletions(-) > >diff --git a/C4/Utils/DataTables.pm b/C4/Utils/DataTables.pm >index e6fc1cc..67023c1 100644 >--- a/C4/Utils/DataTables.pm >+++ b/C4/Utils/DataTables.pm >@@ -85,8 +85,7 @@ sub dt_build_orderby { > my $param = shift; > > my $i = 0; >- my $orderby; >- my @orderbys; >+ my ( @orderbys, $sql_orderby, $es_orderby ); > while(exists $param->{'iSortCol_'.$i}){ > my $iSortCol = $param->{'iSortCol_'.$i}; > my $sSortDir = $param->{'sSortDir_'.$i}; >@@ -95,15 +94,26 @@ sub dt_build_orderby { > ? split(' ', $param->{$mDataProp.'_sorton'}) > : (); > if(@sort_fields > 0) { >- push @orderbys, "$_ $sSortDir" foreach (@sort_fields); >+ push @orderbys, {field => $_, order => $sSortDir} foreach (@sort_fields); > } else { >- push @orderbys, "$mDataProp $sSortDir"; >+ push @orderbys, {field => $mDataProp, order => $sSortDir}; > } > $i++; > } > >- $orderby = " ORDER BY " . join(',', @orderbys) . " " if @orderbys; >- return $orderby; >+ $sql_orderby = >+ " ORDER BY " >+ . join( ',', map { $_->{field} . " " . $_->{order} } @orderbys ) . " " >+ if @orderbys; >+ $es_orderby = [ >+ map { >+ my $f = $_->{field}; >+ $f =~ s|^.*\.||; # Remove table name >+ my $h = { $f => $_->{order} }; >+ $h >+ } @orderbys >+ ]; >+ return { sql => $sql_orderby, es => $es_orderby }; > } > > =head2 dt_build_having >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index a9f1e84..ff57705 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/C4/Utils/DataTables/Members.pm >@@ -102,12 +102,14 @@ sub search { > } > > @conditions = ('*') unless @conditions; >+ my $orderby = dt_build_orderby($dt_params); > my $query = { > query => { > query_string => { > query => join ' AND ', @conditions, > } >- } >+ }, >+ sort => $orderby->{es}, > }; > > # Do not display more than 1000 patrons >diff --git a/C4/Utils/DataTables/VirtualShelves.pm b/C4/Utils/DataTables/VirtualShelves.pm >index 2b37706..f5a6bf4 100644 >--- a/C4/Utils/DataTables/VirtualShelves.pm >+++ b/C4/Utils/DataTables/VirtualShelves.pm >@@ -82,7 +82,7 @@ sub search { > > my $where; > $where = " WHERE " . join (" AND ", @where_strs) if @where_strs; >- my $orderby = dt_build_orderby($dt_params); >+ my $orderby = dt_build_orderby($dt_params)->{sql}; > $orderby =~ s|shelfnumber|vs.shelfnumber| if $orderby; > > my $limit; >-- >2.1.4
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 17500
:
56867
|
56868
|
56869
|
56870
|
56871
|
56872
|
61481
|
61482
|
61483
|
61484
|
61485
|
61486
|
61487