-
Notifications
You must be signed in to change notification settings - Fork 0
Add pagination support to GetAllUserPostQueryService and provide corresponding integration test #208
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
Add pagination support to GetAllUserPostQueryService and provide corresponding integration test #208
Conversation
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.
Pull Request Overview
This PR refactors GetAllUserPostQueryService
to support paginated queries and updates related interfaces and DTOs, along with adding integration tests to verify the new behavior.
- Service now accepts
$perPage
and$currentPage
, uses Laravel’spaginate
, and maps results to aPaginationDto
. - The interface signature was updated to match the new pagination parameters and return type.
- Pagination DTO was expanded (with corrected
from
andto
types) and integration tests were added to seed posts and assert pagination metadata.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/app/Post/Infrastructure/QueryService/GetAllUserPostQueryService.php | Updated service to accept pagination params, use paginate() , and return PaginationDto |
src/app/Post/Infrastructure/InfrastructureTest/GetAllUserPostQueryServiceTest.php | Added integration tests for pagination with dummy posts |
src/app/Post/Application/QueryServiceInterface/GetAllUserPostQueryServiceInterface.php | Updated interface method signature and return type for pagination |
src/app/Common/Application/Dto/Pagination.php | Changed from /to from string to int and expanded constructor parameters |
Files not reviewed (1)
- .idea/workspace.xml: Language not supported
Comments suppressed due to low confidence (3)
src/app/Post/Infrastructure/InfrastructureTest/GetAllUserPostQueryServiceTest.php:35
- The createDummyPosts method is defined but never invoked, so no posts are inserted for the tests. Consider calling createDummyPosts (and refresh) in setUp to seed posts before each test.
parent::setUp();
src/app/Post/Infrastructure/InfrastructureTest/GetAllUserPostQueryServiceTest.php:116
- Test coverage is missing an assertion that the number of items in getData matches the requested perPage. Consider adding an assertion like
$this->assertCount($this->perPage, $result->getData());
to verify page size.
}
src/app/Common/Application/Dto/Pagination.php:11
- [nitpick] Adding a PHPDoc block to explain the purpose of each constructor parameter would improve readability and maintainability of the
Pagination
DTO.
private array $data,
return $this->paginationDto($userPosts->toArray()); | ||
} | ||
|
||
private function paginationDto( |
Copilot
AI
Jun 14, 2025
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.
[nitpick] Consider renaming paginationDto
to buildPaginationDto
to better reflect that this method constructs a PaginationDto
from raw data.
return $this->paginationDto($userPosts->toArray()); | |
} | |
private function paginationDto( | |
return $this->buildPaginationDto($userPosts->toArray()); | |
} | |
private function buildPaginationDto( |
Copilot uses AI. Check for mistakes.
Why
The existing implementation of
GetAllUserPostQueryService
returned all posts associated with a given user without any pagination logic. For scalability and performance, especially when dealing with a large volume of posts, pagination is essential.What
getAllUserPosts
method to accept$perPage
and$currentPage
parameters.paginate
method to fetch paginated user posts.PaginationDto
, mapping each post to a domain entity viaPostFromModelEntityFactory
.paginationDto()
method to handle pagination metadata (e.g.,total
,current_page
,per_page
, etc.).