Issue filtering for first UI code drop (SZ-30)
rk@tigase.net opened 3 weeks ago

Goal

Implement dynamic filtering for the Issue entity to support the following query parameters, in preparation for UI integration:

  • status
  • priority
  • severity
  • projectId
  • (optional) assigneeId and reporterId

This is required to support Issue List views in the first version of the Sztab UI.

Tasks

  •  Create IssueSpecification utility class with static Specification<Issue> methods for each filterable field.
  •  Update IssueRepository to extend JpaSpecificationExecutor<Issue>.
  •  Add controller method to accept optional query parameters and apply combined specification.
  •  Add unit tests for the controller method with various combinations of query parameters.
  •  Add integration test to validate query correctness against seeded H2/PostgreSQL data.

Estimated Time: 3 hours

  • 30m – Define Specification methods for filters
  • 30m – Wire controller and repository
  • 1h – Write unit + integration tests
  • 1h – Validate with sample UI queries and clean up

Notes

  • Follow patterns already used in UserSpecification, ProjectSpecification, etc.
  • Reuse enums like IssueStatus, IssuePriority, IssueSeverity
  • Maintain final on all method parameters
  • Ensure Swagger docs are updated if relevant
  • rk@tigase.net commented 3 weeks ago

    Estimated Time: 3 hours

    • 30m — Define IssueSpecification class and implement Specification<Issue> methods for:

      • status
      • priority
      • severity
      • projectId
      • (optional) assigneeId, reporterId
    • 30m — Update IssueRepository to extend JpaSpecificationExecutor<Issue>, and revise controller to:

      • Accept query parameters via @RequestParam
      • Compose dynamic Specification based on inputs
    • 1h — Write unit tests to cover:

      • All combinations of query parameters
      • Empty queries (return all)
      • Edge cases (invalid enums, etc.)
    • 1h — Write integration tests (H2 or PostgreSQL):

      • Seed multiple issues with different statuses/priorities
      • Validate filtering combinations work as expected
  • rk@tigase.net changed state to 'In Progress' 3 weeks ago
    Previous Value Current Value
    Open
    In Progress
  • rk@tigase.net commented 3 weeks ago

    Work Summary

    This task improves backend support for the upcoming Sztab web UI by enhancing the IssueController with:

    • Pagination validation for getIssuesByFilter(...)
    • Graceful handling of bad requests (invalid page/size)
    • Aligned controller and service method signatures
    • Updated IssueService and IssueServiceImpl
    • Improved JPA IssueSpecification for dynamic filtering
    • Expanded unit test coverage:
      • IssueControllerTest.java: full endpoint coverage including invalid pagination
      • IssueServiceImplTest.java: full path coverage with valid/invalid filters

    Motivation

    The web UI requires paginated and filtered access to issues. This change ensures:

    • Robust API behavior even when pagination inputs are invalid
    • Predictable results for large issue sets
    • A working backend scaffold for the upcoming frontend work

    Changes Made

    Controller

    • IssueController now returns 400 Bad Request for page < 0 or size <= 0
    • Swagger annotations were preserved
    • All controller methods use consistent Javadoc and @PreAuthorize roles

    Service

    • getIssuesByFilter(...) now takes Pageable and filter fields
    • JPA IssueSpecification now lives in its own class

    Tests

    • IssueControllerTest.java: added cases for invalid pagination and filter usage
    • IssueServiceImplTest.java: verified full filtering logic including enums, nulls, and edge cases

    improvement/sz26-sztab-backend-for-web-ui

    Target Branch

    wolnosc (merged and pushed)

    Status

    • Merged
    • Pushed
    • No PR needed (already fully merged into target)
  • rk@tigase.net changed state to 'Closed' 3 weeks ago
    Previous Value Current Value
    In Progress
    Closed
  • rk@tigase.net commented 3 weeks ago

    Worklog

    DateTime SpentTask
    2025-10-291h 15mReviewed existing IssueController and service methods for pagination handling
    2025-10-291h 00mRefactored IssueController to validate page/size params and return 400s
    2025-10-291h 30mIntroduced IssueSpecification for dynamic filtering and updated service methods
    2025-10-291h 00mWrote unit tests for IssueServiceImpl including filter variants
    2025-10-301h 00mExpanded IssueControllerTest with invalid pagination cases
    2025-10-300h 15mMerged into wolnosc, pushed both branches, and verified sync on OneDev

    Total time: 6h 0m

issue 1 of 1
Type
Improvement
Priority
Major
Assignee
Version
none
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
SZ-30
Please wait...
Page is in error, reload to recover