diff options
author | David Lawrence <dkl@mozilla.com> | 2015-07-25 06:21:06 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-07-25 06:21:06 +0200 |
commit | 3331c1bafae2fcaf511db95a0e2b79ab65e25bfe (patch) | |
tree | ef00cceb2667187de4d01f423715abf6e4933c46 /Bugzilla | |
parent | 300331b456392d054f6a85a98aa6a5c56bc37f9b (diff) | |
download | bugzilla-3331c1bafae2fcaf511db95a0e2b79ab65e25bfe.tar.gz bugzilla-3331c1bafae2fcaf511db95a0e2b79ab65e25bfe.tar.xz |
Bug 1161070: api searches should honour the same fields in its "order" parameter as the web UI
r=dylan,a=simon
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/API/1_0/Resource/Bug.pm | 20 | ||||
-rw-r--r-- | Bugzilla/WebService/Bug.pm | 20 |
2 files changed, 38 insertions, 2 deletions
diff --git a/Bugzilla/API/1_0/Resource/Bug.pm b/Bugzilla/API/1_0/Resource/Bug.pm index 6a32a687f..c6ae6a19a 100644 --- a/Bugzilla/API/1_0/Resource/Bug.pm +++ b/Bugzilla/API/1_0/Resource/Bug.pm @@ -716,7 +716,25 @@ sub search { ThrowUserError('buglist_parameters_required'); } - $options{order} = [ split(/\s*,\s*/, delete $match_params->{order}) ] if $match_params->{order}; + # Allow the use of order shortcuts similar to web UI + if ($match_params->{order}) { + # Convert the value of the "order" form field into a list of columns + # by which to sort the results. + my %order_types = ( + "Bug Number" => [ "bug_id" ], + "Importance" => [ "priority", "bug_severity" ], + "Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ], + "Last Changed" => [ "changeddate", "bug_status", "priority", + "assigned_to", "bug_id" ], + ); + if ($order_types{$match_params->{order}}) { + $options{order} = $order_types{$match_params->{order}}; + } + else { + $options{order} = [ split(/\s*,\s*/, $match_params->{order}) ]; + } + } + $options{params} = $match_params; my $search = new Bugzilla::Search(%options); diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 47c047745..c6b28a9a0 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -575,7 +575,25 @@ sub search { ThrowUserError('buglist_parameters_required'); } - $options{order} = [ split(/\s*,\s*/, delete $match_params->{order}) ] if $match_params->{order}; + # Allow the use of order shortcuts similar to web UI + if ($match_params->{order}) { + # Convert the value of the "order" form field into a list of columns + # by which to sort the results. + my %order_types = ( + "Bug Number" => [ "bug_id" ], + "Importance" => [ "priority", "bug_severity" ], + "Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ], + "Last Changed" => [ "changeddate", "bug_status", "priority", + "assigned_to", "bug_id" ], + ); + if ($order_types{$match_params->{order}}) { + $options{order} = $order_types{$match_params->{order}}; + } + else { + $options{order} = [ split(/\s*,\s*/, $match_params->{order}) ]; + } + } + $options{params} = $match_params; my $search = new Bugzilla::Search(%options); |