Bug 414219 - Add support for gerrit changes query options
Summary: Add support for gerrit changes query options
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 2.2   Edit
Assignee: Francois Chouinard CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 414253
  Show dependency tree
 
Reported: 2013-08-01 11:35 EDT by Francois Chouinard CLA
Modified: 2013-12-10 09:45 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois Chouinard CLA 2013-08-01 11:35:14 EDT
The Gerrit Connector currently desn't have support for optional parameters in the gerrit changes query.

For example, to implement the Gerrit Dashboard efficiently, it would be useful to pass the "LABELS" option to the changes query in order to obtain the information needed to populate the "Code-Review" and "Verified" fields. The alternative is to perform requests for review change details and extract the relevant information - a time consumming operation that requires a trip to the back-end for each review.

A simple solution would be to augment the GerritClient API to optionally support query options.

Although the "LABELS" option is of immediate use, the full set of options is quite interesting (hence this bug for some kind of generic support).
Comment 1 Francois Chouinard CLA 2013-08-01 11:35:39 EDT
From the gerrit REST API documentation, the general form of the changes query request is roughly:

GET /changes/?q=<some query>&o=<options>&n=<limit>

where the parameters 'o' and 'n' are optional.

For example (from http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/rest-api-changes.html#change-endpoints):

GET /changes/?q=is:open+owner:self&q=is:open+reviewer:self+-owner:self&q=is:closed+owner:self+limit:5&o=LABELS HTTP/1.0

HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  [
    [
      {
        "kind": "gerritcodereview#change",
        "id": "demo~master~Idaf5e098d70898b7119f6f4af5a6c13343d64b57",
        "project": "demo",
        "branch": "master",
        "change_id": "Idaf5e098d70898b7119f6f4af5a6c13343d64b57",
        "subject": "One change",
        "status": "NEW",
        "created": "2012-07-17 07:18:30.854000000",
        "updated": "2012-07-17 07:19:27.766000000",
        "reviewed": true,
        "mergeable": true,
        "_sortkey": "001e7057000006dc",
        "_number": 1756,
        "owner": {
          "name": "John Doe"
        },
        "labels": {
          "Verified": {},
          "Code-Review": {}
        }
      }
    ],
    [],
    []
  ]
Comment 2 Francois Chouinard CLA 2013-08-01 11:46:57 EDT
Proposed fix pushed to gerrit (9ab99bc)

GerritClient.executeQueryRest() is responsible for formatting the query string (uri). The proposed solution is to augment its API with an optional optionString. It is fairly simple to ensure backward compatibility for the existing code by overloading a couple of methods.

Note that this solution only applies to the REST API (gerrit 2.5+).
Comment 3 Tomasz Zarna CLA 2013-08-08 12:08:55 EDT
(In reply to comment #0)
> For example, to implement the Gerrit Dashboard efficiently, it would be useful
> to pass the "LABELS" option to the changes query 

Does it mean this bug blocks bug 414253 ?
Comment 4 Francois Chouinard CLA 2013-08-08 15:58:42 EDT
> 
> Does it mean this bug blocks bug 414253 ?

Yes. I added the dependency.
Comment 5 Tomasz Zarna CLA 2013-08-09 05:21:52 EDT
(In reply to comment #2)
> Proposed fix pushed to gerrit (9ab99bc)

It' https://git.eclipse.org/r/#/c/15044/

> Note that this solution only applies to the REST API (gerrit 2.5+).

That's too bad. Any chance to produce the same output for 2.4 (it's still supported)?

Also, see my comments on the review.
Comment 6 Steffen Pingel CLA 2013-12-10 09:45:40 EST
I think all reviews related to this bug have been merged. Thanks!