-
-
Notifications
You must be signed in to change notification settings - Fork 116
feat(api): Add sortOrder to API_GetComments #3156
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
Conversation
|
FYI – I am open to a different query letter here |
public/API/API_GetComments.php
Outdated
| * 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.
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.
Cool, I will check on this next week. Thanks for looking at it
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.
Hello, it is I! Finally making finishing this a priority, apologies for the PR and run.
I just pushed a commit that accepts submitted and -submitted as the s param. I am willing to add others to the sortOptions enum, but wanted to verify this is the pattern you were thinking @wescopeland.
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.
Yep, I think so. I would rename it to sort to align with some of our other paths like: https://retroachievements.org/games?sort=-achievementsPublished
public/API/API_GetComments.php
Outdated
| * 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.
wescopeland
left a comment
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.
LGTM - we just need an accompanying docs PR before we can ship this in a release.
Awesome, thanks! Will push docs PR tomorrow. |
Alter the GetComments endpoint from #2552 to add a sortOrder query param