Skip to content

Feature: Pagination, Search, Filtering and Sorting (Notes and Quizzes)#16

Merged
pvdev1805 merged 6 commits intodevelopfrom
feature/pagination
Feb 3, 2026
Merged

Feature: Pagination, Search, Filtering and Sorting (Notes and Quizzes)#16
pvdev1805 merged 6 commits intodevelopfrom
feature/pagination

Conversation

@TUT888
Copy link
Owner

@TUT888 TUT888 commented Jan 27, 2026

Summary

This PR introduces pagination, search, filtering, and sorting capabilities for the notes and quizzes features.

Detail changes

Pagination

  • Added a new PageResponse<T> class that standardizes paginated responses by containing both the page metadata (current page, total pages, page size, total elements) and the page content.
  • Updated repositories to return Page<T> instead of List<T> to prevent loading large datasets into memory.
  • Refactored service-layer getAll methods to use Spring Data’s Pageable instead of retrieving all records. The service now:
    • Builds a Pageable object (with pagination + sorting).
    • Retrieves a Page<T> from the repository.
    • Maps the page content into DTOs and wraps the result in PageResponse<T>.
  • Updated controllers to accept optional page and size parameters. If omitted, default values from common/DefaultConstants.java are applied

Search and Filtering

  • Updated repositories to extend JpaSpecificationExecutor<T> to support dynamic filtering via JPA Specifications.
  • Added filter DTOs for mapping query parameters using @ModelAttribute:
    • BasicFilterDTO: supports keyword search and date-range filtering.
    • QuizFilterDTO: extends BasicFilterDTO and adds quizSetId for filtering quizzes belonging to a specific quiz set.
  • Implemented predicate builders and specification builders:
    • CommonPredicateBuilder: provides reusable predicate helpers to reduce duplication across specifications.
    • NoteSpecificationBuilder, QuizSpecificationBuilder, and QuizSetSpecificationBuilder: construct entity-specific filtering logic used by repositories.

Sorting

  • Updated controllers to accept sortBy and sortOrder parameters. Defaults to sorting by updatedAt in descending order.
  • Updated services to incorporate sorting into the Pageable configuration before querying the repository.

Testing

  • Added new tests covering pagination behavior for NoteService, NoteController and DocumentRepository.

Remaining & Upcomming Works

  • Current tests only cover pagination. Additional tests are needed for search, filtering, and sorting.
  • This PR only implements the new functionality for notes and quizzes. Other features (e.g., flashcards) will require similar updates

Copy link
Collaborator

@pvdev1805 pvdev1805 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the changes, all features tested and working as expected.

@pvdev1805 pvdev1805 merged commit c93c1ab into develop Feb 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants