-
Notifications
You must be signed in to change notification settings - Fork 3
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 public endpoint for querying wikis #635
Conversation
ff49ecf
to
2c75c93
Compare
*/ | ||
public function show($id) | ||
{ | ||
return new PublicWikiResource(Wiki::findOrFail($id)); |
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 allows clients to look up wikis by their integer id. Instead, we could also look them up by domain and hide the id from the public, not sure if I have a preference.
406659e
to
a984c35
Compare
routes/api.php
Outdated
@@ -22,6 +22,8 @@ | |||
$router->post('user/resetPassword', ['uses' => 'Auth\ResetPasswordController@reset']); | |||
$router->post('contact/sendMessage', ['uses' => 'ContactController@sendMessage']); | |||
|
|||
$router->apiResource('wiki', 'PublicWikiController'); |
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.
Not sure if this needs stricter throttling than the default one? Current settings allows for 45 request to be made in one minute per IP. I am not sure however if we actually see the forwarded IP or if this is effectively a global setting, throttling the "ingress client".
fa3d97a
to
1d752fa
Compare
26661e7
to
9717f24
Compare
'is_featured' => 'boolean', | ||
'is_active' => 'boolean', | ||
'per_page' => 'numeric', | ||
'page' => 'numeric' |
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.
The page
parameter is somehow magically picked up by Laravel itself, we never pass it on or look at it. Not sure if we need to validate it, but I thought it might be good to put it here so all possible query params are documented here.
} | ||
|
||
if (array_key_exists('is_active', $params) && $params['is_active']) { | ||
$query = $query->whereRelation('wikiSiteStats', 'pages', '>', 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.
The ticket currently say > 1
, I need to double check if this is correct or needs to be changed.
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.
The ticket is correct. I fixed this to be > 1
3d044a5
to
ee5c4bd
Compare
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.
Everything is great in my eyes. Didn't catch anything off
ee5c4bd
to
e692b26
Compare
Ticket https://phabricator.wikimedia.org/T344581
Pagination behavior is documented here: https://laravel.com/docs/8.x/eloquent-resources#pagination, i.e. the UI can pass
per_page
andpage
, and reads cursor info in themeta
property.Available
sort
options arepages
andsitename
(default) withdirection
values ofasc
(default) anddesc
.