Bug 1956944

Summary: Search order by last change time using the REST API
Product: [Community] Bugzilla Reporter: Tristan Cacqueray <tdecacqu>
Component: Query/Bug ListAssignee: Jeff Fearn 🐞 <jfearn>
Status: CLOSED DUPLICATE QA Contact: Utkarsh <ubajpei>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.0CC: apevec, fboucher
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-06 02:24:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tristan Cacqueray 2021-05-04 17:51:05 UTC
Description of problem:

The REST API search endpoint does not seem to support the `order` parameter.
We would like to query bugs ordered by the last_change_time, so that we can safely use offset + limit to advance in time.


Steps to Reproduce:

Using this base query (for bugs with external links):

```
BZQ=https://bugzilla.redhat.com/rest/bug?limit=5&include_fields=summary,id,last_change_time,creation_time&f1=ext_bz_bug_map.ext_bz_bug_id&o1=isnotempty
```

1. curl ${BZQ}&order=Last Updated
2. curl ${BZQ}&order=Last Updated&chfieldfrom=2021-04-04


Actual results:

1. Bugs ordered by creation time
2. Bugs updated after 2021-04-04, ordered by creation time


Expected results:

The bugs should be ordered by their last update time.

To work around that limitation, we need to collect all the bugs and compute what is the last update time.
Then for the next query, we can start over from this date using the `chfieldfrom` parameter.
However this can miss bug that are updated during the collection.


Additional info:

A sort order (ascending/descending) would be useful too.

Setting order to `last_change_time` does not seem to work either.

Comment 1 Jeff Fearn 🐞 2021-05-04 23:15:57 UTC
'order=changeddate' seems to work, as does 'order=changeddate DESC'.

Comment 2 Tristan Cacqueray 2021-05-05 00:08:56 UTC
Thanks, that works. Is this documented somewhere?

Comment 3 Jeff Fearn 🐞 2021-05-05 00:21:19 UTC
No, there is a bug to document it, but it bridges the internal/external divide so is pretty ugly.

Comment 4 Jeff Fearn 🐞 2021-05-06 02:24:14 UTC

*** This bug has been marked as a duplicate of bug 1264787 ***

Comment 5 Tristan Cacqueray 2021-05-06 11:30:40 UTC
Thank you Jeff for the quick solution.