-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
✨Feature: Allows random endpoints to return multiple items #559
base: master
Are you sure you want to change the base?
Conversation
Also resolves #490 |
These changes seem to break the anime filtering and anime season logic. See tests for details. 😟 |
Woops, missed this. Looking into. |
…jikan-rest into feature/multiplerandom
@@ -24,7 +25,7 @@ public function __construct(private readonly AnimeRepository $repository) | |||
public function handle($request) | |||
{ | |||
$requestParams = collect($request->all()); | |||
$limit = $requestParams->get("limit"); | |||
$limit = $request->limit instanceof Optional ? max_results_per_page() : $request->limit; |
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 is repeating code, shouldn't we either change the PreparesData
to replace Optional with this?
Can you also add tests for the new endpoints please? 😄 I don't want to break them in the future 😄 Just add tests to the files with |
This addresses #433
Important notes
limit
usage a bit so the default25
is not set if nolimit
property is in querylimit
for Random endpoints is 5 to test the waters. There is a performance drop associated with a large sample size. Larger datasets likeUsers
response slower compared toAnime
.MaxResultsPerPageRule
and allows override from theMaxLimitWithFallback
traitAdditional notes
$defaultLimit
override does not work in DTOsmax_results_per_page(property_exists(static::class, "defaultLimit") ? static::$defaultLimit : null))
max_results_per_page
does not override with $defaultLimit`. The return value will always be what's in the config. We'll need to approach this differently in case we need to allow for dynamic overrides per DTO command.I've commented out this part. We should probably check for
$limit instanceof Spatie\LaravelData\Optional
within the Handler.