Skip to content

Add paginated active lamp retrieval to repository#417

Merged
davideme merged 1 commit intomainfrom
codex/review-issue-411-reference
Feb 23, 2026
Merged

Add paginated active lamp retrieval to repository#417
davideme merged 1 commit intomainfrom
codex/review-issue-411-reference

Conversation

@davideme
Copy link
Owner

Summary

  • add pageable overloads for active lamp queries in repository interfaces and implementations
  • update lamp service pagination to request pageSize+1 rows and honor hasMore via the new query path
  • expand unit/integration tests to cover the paged active window and service behavior

Testing

  • Not run (not requested)

Copilot AI review requested due to automatic review settings February 23, 2026 10:07
Copy link
Contributor

Copilot AI left a 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 pull request adds paginated active lamp retrieval capabilities to the repository layer and updates the service to use an efficient pageSize+1 pagination pattern for determining hasMore without requiring separate count queries.

Changes:

  • Added paginated findAllActive(Pageable) methods to repository interfaces and all implementations (JPA, in-memory, adapter)
  • Updated LampService.findAllActivePage() to use the new paginated query method with pageSize+1 pattern for efficient hasMore detection
  • Added comprehensive unit and integration tests covering pagination behavior, ordering, soft-delete filtering, and edge cases

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/java/src/main/java/org/openapitools/repository/LampRepository.java Added paginated findAllActive(Pageable) method signature with documentation
src/java/src/main/java/org/openapitools/repository/JpaLampRepository.java Implemented paginated findAllActive with JPQL query ordering by createdAt and id
src/java/src/main/java/org/openapitools/repository/impl/InMemoryLampRepository.java Implemented paginated findAllActive with in-memory sorting and windowing
src/java/src/main/java/org/openapitools/config/RepositoryConfig.java Added adapter method to forward paginated findAllActive calls to JPA repository
src/java/src/main/java/org/openapitools/service/LampService.java Refactored pagination to use pageSize+1 pattern with new repository method
src/java/src/test/java/org/openapitools/service/LampServiceTest.java Updated unit tests to verify pageSize+1 behavior and hasMore calculation
src/java/src/test/java/org/openapitools/repository/LampRepositoryTest.java Added tests for paginated active lamp retrieval with ordering verification
src/java/src/test/java/org/openapitools/integration/JpaLampRepositoryIntegrationTest.java Added integration test for paginated active lamp window with soft-delete filtering

@@ -48,6 +49,18 @@ public interface JpaLampRepository extends JpaRepository<LampEntity, UUID> {
@Query("SELECT l FROM LampEntity l WHERE l.deletedAt IS NULL ORDER BY l.createdAt ASC")
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The non-paginated findAllActive() method only orders by createdAt, while the paginated version (line 61) orders by createdAt and id. This inconsistency could cause different ordering when lamps have the same createdAt timestamp. For deterministic and consistent results, consider updating this query to also include id as a secondary sort: ORDER BY l.createdAt ASC, l.id ASC

Suggested change
@Query("SELECT l FROM LampEntity l WHERE l.deletedAt IS NULL ORDER BY l.createdAt ASC")
@Query(
"SELECT l FROM LampEntity l WHERE l.deletedAt IS NULL ORDER BY l.createdAt ASC, l.id ASC")

Copilot uses AI. Check for mistakes.
Comment on lines 142 to 143
.sorted(Comparator.comparing(LampEntity::getCreatedAt))
.toList();
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The non-paginated findAllActive() method only orders by createdAt, while the paginated version orders by createdAt and id. This inconsistency could cause different ordering when lamps have the same createdAt timestamp. For deterministic and consistent results, consider updating this sort to also include id as a secondary comparator: .sorted(Comparator.comparing(LampEntity::getCreatedAt).thenComparing(LampEntity::getId))

Copilot uses AI. Check for mistakes.
@davideme davideme merged commit c0abfb0 into main Feb 23, 2026
8 checks passed
@davideme davideme deleted the codex/review-issue-411-reference branch February 23, 2026 10:14
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