feat(ab-testing): Add pagination to getAllExperiments() endpoint (#1390) - #1405
Open
chrissarah054-dotcom wants to merge 1 commit into
Open
Conversation
…afcode#1390) BREAKING CHANGE: Response format changed from array to paginated object - Replace unbounded find() with paginated createQueryBuilder() + getManyAndCount() - Remove eager loading of variants/metrics from list view (performance optimization) - Add PaginationQueryDto support for page, limit, sortBy, order parameters - Implement SQL injection prevention via sortBy field whitelist validation - Return OffsetPaginatedResponse with metadata (total, page, hasNextPage, etc.) - Configure default page size: 10 items, max: 100 items per PAGE_SIZE constants Performance improvements: - Query time: O(n) -> O(1) constant regardless of total experiments - Memory: O(n×m) unbounded -> O(limit) bounded by page size - Response size: Unbounded -> Capped at 100 items maximum - Database: Eliminated N+1 query problem via single getManyAndCount() Database optimization: - List view (getAllExperiments): No relation eager loading for bounded queries - Detail view (getExperimentById): Maintains full relations (variants, metrics) - Indexed createdAt field provides fast sorting and offset pagination API Changes: Before: GET /ab-testing/experiments -> Experiment[] After: GET /ab-testing/experiments -> OffsetPaginatedResponse<Experiment> Supported query parameters: - page (1-based, default: 1) - limit (1-100, default: 10) - sortBy (createdAt, updatedAt, name, status, startDate; default: createdAt) - order (ASC, DESC; default: DESC) Tests: - Added 8 comprehensive pagination test cases - Coverage: default pagination, skip/take math, sorting, SQL injection prevention, metadata calculation, no eager loading verification, page size clamping, edge cases Docs: - Full Swagger/OpenAPI documentation with examples - Implementation summary with migration guide - Performance comparison (before/after metrics)
|
@chrissarah054-dotcom Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Well done on the job done so far! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1390
BREAKING CHANGE: Response format changed from array to paginated object
Performance improvements:
Database optimization:
API Changes:
Before: GET /ab-testing/experiments -> Experiment[]
After: GET /ab-testing/experiments -> OffsetPaginatedResponse
Supported query parameters:
Tests:
Docs: