Skip to content

Commit

Permalink
Bug 1184828: backport bug 1161070 to bmo (api searches should honour …
Browse files Browse the repository at this point in the history
…the same fields in its "order" parameter as the web UI)
  • Loading branch information
dklawren committed Jul 24, 2015
1 parent 50c7dab commit 92f16f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
20 changes: 19 additions & 1 deletion Bugzilla/WebService/Bug.pm
Expand Up @@ -611,7 +611,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);
Expand Down
35 changes: 12 additions & 23 deletions buglist.cgi
Expand Up @@ -681,29 +681,18 @@ my @order_columns;
if ($order) {
# Convert the value of the "order" form field into a list of columns
# by which to sort the results.
ORDER: for ($order) {
/^Bug Number$/ && do {
@order_columns = ("bug_id");
last ORDER;
};
/^Importance$/ && do {
@order_columns = ("priority", "bug_severity");
last ORDER;
};
/^Assignee$/ && do {
@order_columns = ("assigned_to", "bug_status", "priority",
"bug_id");
last ORDER;
};
/^Last Changed$/ && do {
@order_columns = ("changeddate", "bug_status", "priority",
"assigned_to", "bug_id");
last ORDER;
};
do {
# A custom list of columns. Bugzilla::Search will validate items.
@order_columns = split(/\s*,\s*/, $order);
};
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{$order}) {
@order_columns = @{ $order_types{$order} };
}
else {
@order_columns = split(/\s*,\s*/, $order);
}
}

Expand Down

0 comments on commit 92f16f7

Please sign in to comment.