Project

General

Profile

Bug #18341

API sort hash is not working, but sort_by and sort_order are working but undocumented

Added by Tomáš Strachota over 2 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1138262

Description of problem:
In the API the order option is working. The documented sort hash is not working. There are undocumented sort_by and sort_order that are working instead.

Not working sort hash:

# curl -K /opt/hoici/etc/curl-admin.conf -H 'Content-Type: application/json' -d '{"per_page":"9999","sort":{"by":"name","order":"desc"}}' -XGET https://localhost/katello/api/v2/organizations/4/products | jq . | tail -n10
  "sort": {
    "order": null,
    "by": null
  },
  "search": null,
  "per_page": "9999",
  "page": 1,
  "subtotal": 19,
  "total": 19
}

Working order:

# curl -K /opt/hoici/etc/curl-admin.conf -H 'Content-Type: application/json' -d '{"per_page":"9999","order":"name desc"}' -XGET https://localhost/katello/api/v2/organizations/4/products | jq . | tail -n10
  "sort": {
    "order": "desc",
    "by": "name" 
  },
  "search": null,
  "per_page": "9999",
  "page": 1,
  "subtotal": 19,
  "total": 19
}

Working sort_by and sort_order:

# curl -K /opt/hoici/etc/curl-admin.conf -H 'Content-Type: application/json' -d '{"per_page":"9999","sort_by":"name","sort_order":"desc"}' -XGET https://localhost/katello/api/v2/organizations/4/products | jq . | tail -n 10
  "sort": {
    "order": "desc",
    "by": "name" 
  },
  "search": null,
  "per_page": "9999",
  "page": 1,
  "subtotal": 19,
  "total": 19
}

Expected results:
Consistent API functionality and documentation for sorting the results


Related issues

Blocks Hammer CLI - Bug #18340: Hammer params for ordering are inconsistentClosed

Associated revisions

Revision 0488a25f (diff)
Added by Oleh Fedorenko 11 months ago

Fixes #18341 - Documented sort parameters

History

#1 Updated by Tomáš Strachota over 2 years ago

  • Blocks Bug #18340: Hammer params for ordering are inconsistent added

#2 Updated by Justin Sherrill over 2 years ago

  • Subject changed from API sort hash is not working, but sort_by and sort_order are working but undocumented to API sort hash is not working, but sort_by and sort_order are working but undocumented
  • Category set to API
  • Legacy Backlogs Release (now unused) set to 114

#3 Updated by Tomáš Strachota over 1 year ago

Ideally we unify the parameters with 'order' and 'by' that foreman uses today.
The steps should be:
  • document the params correctly in the API of Katello
  • fix the systems to use only one set of params for ordering (backward compatibility needs to be kept)
  • add deprecation warnings when the old params are used

#4 Updated by The Foreman Bot 11 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/7707 added

#5 Updated by Oleh Fedorenko 11 months ago

  • Assignee deleted (Bryan Kearney)

Assigned to Oleh Fedorenko (https://projects.theforeman.org/users/9990)

Also the description is not quite correct.

Working order actually:

# curl -K /opt/hoici/etc/curl-admin.conf -H 'Content-Type: application/json' -d '{"per_page":"9999","order":"name desc"}' -XGET https://localhost/katello/api/v2/organizations/4/products | jq . | tail -n10
  "sort": {
    "order": "desc",
    "by": "name" 
  },
  "search": null,
  "per_page": "9999",
  "page": 1,
  "subtotal": 19,
  "total": 19
}

and not working sort hash:

# curl -K /opt/hoici/etc/curl-admin.conf -H 'Content-Type: application/json' -d '{"per_page":"9999","sort":{"by":"name","order":"desc"}}' -XGET https://localhost/katello/api/v2/organizations/4/products | jq . | tail -n10
  "sort": {
    "order": null,
    "by": null
  },
  "search": null,
  "per_page": "9999",
  "page": 1,
  "subtotal": 19,
  "total": 19
}

#6 Updated by Tomáš Strachota 11 months ago

  • Description updated (diff)

I mixed section headings when I was reporting the bug. Sorry for that, it's fixed now.

#7 Updated by Oleh Fedorenko 11 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF