-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): Add sortOrder to API_GetComments #3156
base: master
Are you sure you want to change the base?
feat(api): Add sortOrder to API_GetComments #3156
Conversation
FYI – I am open to a different query letter here |
@@ -15,6 +15,7 @@ | |||
* t : 1 = game, 2 = achievement, 3 = user | |||
* o : offset - number of entries to skip (default: 0) | |||
* c : count - number of entries to return (default: 100, max: 500) | |||
* s : sortOrder - sort comments. 0 = ascending, 1 = descending (default: 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be too ambiguous in terms of what the orderBy()
is. I'm also thinking integers as possible values may be inflexible if this pattern is extended to other API endpoints.
I think we may want to change this to use JSON:API-like enum values, ie: createdAt
and -createdAt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a few public APIs where filter parameters are effectively booleans (0=all,1=filtered), and some that are direct mapping of enums (3=core,5=unofficial).
But as this is not an enum, and it's not being implemented as a boolean (s: sort descending (0=no,1=yes)
), I agree that it makes sense to have it be more free-form.
@@ -15,6 +15,7 @@ | |||
* t : 1 = game, 2 = achievement, 3 = user | |||
* o : offset - number of entries to skip (default: 0) | |||
* c : count - number of entries to return (default: 100, max: 500) | |||
* s : sortOrder - sort comments. 0 = ascending, 1 = descending (default: 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a few public APIs where filter parameters are effectively booleans (0=all,1=filtered), and some that are direct mapping of enums (3=core,5=unofficial).
But as this is not an enum, and it's not being implemented as a boolean (s: sort descending (0=no,1=yes)
), I agree that it makes sense to have it be more free-form.
|
||
if ($sortOrder == 1) { | ||
$commentsQuery->orderBy('Submitted', 'DESC'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll probably want an explicit orderBy
for ascending to. It's unsafe to assume that an unordered query returns sorted data.
Alter the GetComments endpoint from #2552 to add a sortOrder query param
*/