Closed Bug 1161070 Opened 9 years ago Closed 9 years ago

api searches should honour the same fields in its "order" parameter as the web UI

Categories

(Bugzilla :: WebService, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 6.0

People

(Reporter: glob, Assigned: dkl)

Details

Attachments

(1 file, 2 obsolete files)

api searches should honour the same fields in its "order" parameter as the web UI.

eg. "Last Changed" --> "changeddate"
Here is the code from buglist.cgi that the API would need to mimic

        /^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;
        };
Assignee: nobody → dkl
Status: NEW → ASSIGNED
Attached patch 1161070_1.patch (obsolete) — Splinter Review
Attachment #8602143 - Flags: review?(dylan)
Comment on attachment 8602143 [details] [diff] [review]
1161070_1.patch

Review of attachment 8602143 [details] [diff] [review]:
-----------------------------------------------------------------

r- I think using for/last and regexes that match fixed strings is pretty inefficient and hard to understand. Perhaps something like this would work?

    # Allow the use of order shortcuts similar to web UI
	
    my @order_columns;
    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" ],
        );
        $options{order} = $order_types{ $match_params->{order} } // [split(/\s*,\s*/, $match_params->{order})];
    }
Attachment #8602143 - Flags: review?(dylan) → review-
I am thinking now that this could be useful upstream as well.

dkl
Component: API → WebService
Product: bugzilla.mozilla.org → Bugzilla
QA Contact: default-qa
Version: Production → 5.1
Attached patch 1161070_2.patch (obsolete) — Splinter Review
Attachment #8602143 - Attachment is obsolete: true
Attachment #8602186 - Flags: review?(dylan)
Comment on attachment 8602186 [details] [diff] [review]
1161070_2.patch

Review of attachment 8602186 [details] [diff] [review]:
-----------------------------------------------------------------

r- for the scalar-context issue with ||. Sorry :(

::: buglist.cgi
@@ +651,5 @@
> +        "Assignee"     => [ "assigned_to", "bug_status", "priority", "bug_id" ],
> +        "Last Changed" => [ "changeddate", "bug_status", "priority",
> +                            "assigned_to", "bug_id" ],
> +    );
> +    @order_columns = @{ $order_types{ $order } || [] } || split(/\s*,\s*/, $order);

subtle bug here I almost didn't notice, the left-hand-side of || is evaluated in scalar context, so the @order_columns will always be the last item in $order_types{ $order }.
Attachment #8602186 - Flags: review?(dylan) → review+
Comment on attachment 8602186 [details] [diff] [review]
1161070_2.patch

Woops, that was an r-
Attachment #8602186 - Flags: review+ → review-
Attached patch 1161070_3.patchSplinter Review
Attachment #8602186 - Attachment is obsolete: true
Attachment #8629035 - Flags: review?(dylan)
Attachment #8629035 - Flags: review?(dylan) → review+
Flags: approval?
Flags: approval? → approval+
Target Milestone: --- → Bugzilla 6.0
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   300331b..3331c1b  master -> master
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: