Skip to content

[PRAC-258] Fix pagination - #116

Merged
Kuba0517 merged 1 commit into
mainfrom
fix/PRAC-258-fix-pagination
Jan 25, 2026
Merged

[PRAC-258] Fix pagination#116
Kuba0517 merged 1 commit into
mainfrom
fix/PRAC-258-fix-pagination

Conversation

@Kuba0517

@Kuba0517 Kuba0517 commented Jan 25, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Server-driven pagination added across moderation views (reports, users, logs) with page navigation and total-pages support.
    • Reports list now fetches paged data from the API and includes pagination controls; filtering resets to first page.
  • Bug Fixes

    • Consistent pagination parameter handling across moderation endpoints and UI.
  • Chores

    • Updated API schemas and client hooks to support flat page/size parameters and paged responses.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR standardizes pagination across the moderation module by replacing Spring Pageable objects with explicit page/size parameters in backend controllers and services, adds paged repository methods, adapts frontend API schemas and hooks to the new shapes, and adjusts moderator UI components to consume paged responses (including reports pagination).

Changes

Cohort / File(s) Summary
Backend Controller Pagination Refactoring
backend/src/main/java/com/codu/dev/moderation/api/ModerationController.java
Endpoints getAllUsers, getReports, and getLogs now accept explicit @RequestParam int page and @RequestParam int size (defaults 0 and 10). getReports now returns Page<ReportModerationDTO>.
Backend Service Interface Updates
backend/src/main/java/com/codu/dev/moderation/service/ModerationService.java
Signatures changed to (int page, int size) for getAllUsers and getModerationLogs; getReports now accepts (ReportStatus status, int page, int size) and returns Page<ReportModerationDTO>. New method deleteUser(UUID userId, UUID moderatorId) added.
Backend Service Implementation
backend/src/main/java/com/codu/dev/moderation/service/ModerationServiceImpl.java
Implementations switched to use PageRequest.of(page, size) and return Page<*> for users, reports, and logs. Replaced Pageable usage with explicit PageRequest.
Backend Repository Enhancement
backend/src/main/java/com/codu/dev/report/infra/persistence/repository/ReportRepository.java
Added paginated repository methods: findAllByIsDeletedFalseOrderByCreatedAtDesc(Pageable) and findAllByStatusAndIsDeletedFalseOrderByCreatedAtDesc(ReportStatus, Pageable) with EntityGraph annotations.
Frontend API Schema Changes
frontend/src/lib/api/schemas/* (getAllUsers1Params.ts, getLogsParams.ts, getReportsParams.ts, pageReportModerationDTO.ts, pageableObject.ts, index.ts)
Replaced { pageable: Pageable } params with flattened page?: number; size?: number; added PageReportModerationDTO paged response type and re-exported it; minor property reorder in PageableObject.
Frontend API Hook & Client Updates
frontend/src/lib/api/moderation-controller/moderation-controller.ts
Hook/query option overloads updated to accept optional params; getReports return type changed to paged DTO; callers can omit params object.
Frontend Page Components
frontend/src/app/(staff)/moderator/* (logs/page.tsx, users/page.tsx, reports/page.tsx)
Calls updated from nested { pageable: { page, size } } to flat { page, size }. Reports page introduces PAGE_SIZE, reads response.data?.content and response.data?.totalPages.
Frontend Moderation Tables
frontend/src/features/moderation/* (users-table.tsx, moderation-logs-table.tsx)
Hook invocations updated to pass { page, size } top-level parameters; data handling largely unchanged.
Frontend Reports Table Enhancement
frontend/src/features/moderation/reports-table.tsx
Switched to server-driven paged fetching via useGetReports, added currentPage state and pagination handlers, derive reports from response.data?.content, and expanded ReportsTable props to accept initialTotalPages.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇
I hopped through pages, one and two,
Flattened params and fetched anew,
Content comes paged, neat and bright,
Moderation hops with lighter flight.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kuba0517
Kuba0517 force-pushed the fix/PRAC-258-fix-pagination branch from 19cf6e0 to 929ee23 Compare January 25, 2026 22:34
@Kuba0517
Kuba0517 merged commit ff016c3 into main Jan 25, 2026
10 checks passed
@Kuba0517
Kuba0517 deleted the fix/PRAC-258-fix-pagination branch January 25, 2026 22:37
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.

1 participant