fix(ccsph2n): court-calendar courtscheduler search — de-duplicate per day & exclude drafts [SPRDT-1164]#39
Open
ozturkmenb wants to merge 5 commits into
Open
Conversation
… day and exclude drafts [SPRDT-1164] The court-calendar range-search courtscheduler path (RangeSearchQuery PATH A, getCourtSchedulerHearings) mutated and re-added a single shared Hearing instance per returned hearing-day, collapsing multi-day hearings onto their last day; it also never applied the allocated filter, so draft/unallocated sessions leaked into the allocated view. - Hearing: add copy constructor that deep-copies properties (per-row flatten mutates it), so day-copies cannot corrupt each other. - RangeSearchQuery.enrichAllCourtSchedulerHearingIdsIntoHearings: build one Hearing per IdResponse (distinct per-day rows) and skip non-allocated base hearings. - getCourtSchedulerHearings: report the de-duplicated/allocated row count when the result set fits on one page; keep the courtscheduler total for genuinely paged results. - Unit tests for per-day split and draft exclusion; CROWN PATH-A integration test. ouCode routing is deliberately left unchanged (deferred).
…IT (Sonar S2699) [SPRDT-1164]
ragubalan
approved these changes
Jul 14, 2026
…er + listing-side hearingType filter + dedupe [SPRDT-1164] Reworks the court-calendar range-search courtscheduler path (RangeSearchQuery PATH A): - Draft (unallocated) court-schedule sessions are now excluded at source: when the request is allocated=true, isDraft=false is passed to courtscheduler get.hearing.ids. The previous listing-side allocated filter and single-page count adjustment are removed (single filter home). Pagination/count are left as main: the caller's pageSize is forwarded and the courtscheduler results count is passed straight through. - hearingType is filtered listing-side (viewstore typeId), since courtscheduler has no hearing type. - hearingIds are de-duplicated before the viewstore fetch. - the per-day Hearing copy (multi-day split) is retained. The plain (non-court-calendar) range-search path is unchanged (isDraft/hearingType passed as null). CourtSchedulerServiceAdapter.getCourtSchedulerHearings gains a nullable isDraft param, added to the courtscheduler query only when non-null. Tests: RangeSearchQueryTest (+5), CourtSchedulerServiceAdapterTest (+2); court-calendar IT shouldRouteCourtCalendarPathAByCourtSessionAndFilterByHearingType covers Any/AM/AD and the hearingType filter (PATH A + PATH B routing). Full listing IT suite: 258 passed, 0 failures, 3 skipped.
Author
|
Follow-up on SPRDT-1164 — pushed
Companion courtscheduler PR (adds the Tests: |
…raft filter, drop duplicate isDraft [SPRDT-1164] The court-calendar PATH A draft filter now rides the courtscheduler get.hearing.ids endpoint's pre-existing `status` param (DRAFT/FINAL/ALL) instead of a dedicated isDraft flag: PATH A sends status=FINAL when allocated=true. CourtSchedulerServiceAdapter.getCourtSchedulerHearings takes a nullable `status` (added to the query only when non-null); the pre-existing IS_DRAFT constant is left untouched (used by unrelated wire fields). hearingType (listing-side) filter, dedupe, per-day copy and main-parity pagination/count are unchanged. Behaviourally identical to the previous isDraft=false (FINAL == non-draft); removes duplicate API surface. Tests: CourtSchedulerServiceAdapterTest 24/24 (asserts status=FINAL on the query), RangeSearchQueryTest 38/38. Court-calendar IT unchanged (stubs on courtSession) — full listing IT suite still 258/0.
…onar java:S2699) [SPRDT-1164] shouldRouteCourtCalendarPathAByCourtSessionAndFilterByHearingType relied solely on pollWithDefaults(...).until(...) matchers, which SonarQube's java:S2699 does not recognise as assertions. Capture the final polled ResponseData and assert on its payload explicitly.
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.
What & why
The Crown court-calendar range-search (
GET .../listing/hearings/range-search,court.calendarmedia) has a courtscheduler-backed code path (RangeSearchQueryPATH A →getCourtSchedulerHearings), taken when a specific session +ouCode+allocated=trueare supplied. Two defects there produced the reported UI bug (blank hearing start-times, duplicate rows,undefinedcourtroom):Hearinginstance per id and mutated + re-added that same reference for every returned hearing-day; the per-row flatten also mutates the sharedpropertiesJsonNode. A multi-day hearing therefore collapsed onto its last day (e.g. a 3-day hearing rendered 3× all on day 3).allocated=true, yet it never applied an allocated filter, so draft/unallocated courtscheduler sessions leaked into the allocated view (and inflated the result count).Full RCA: https://tools.hmcts.net/confluence/spaces/LPT/pages/1990370971 · Decision: ADR-006
Changes
Hearing(viewstore entity): copy constructor that deep-copiespropertiesso per-day copies can't corrupt each other during flatten.RangeSearchQuery.enrichAllCourtSchedulerHearingIdsIntoHearings: build oneHearingperIdResponse(distinct per-day rows) and skip non-allocated base hearings.RangeSearchQuery.getCourtSchedulerHearings: report the de-duplicated/allocated row count when the result set fits on one page; keep the courtscheduler total for genuinely paged results (pagination-safe —RangeSearchQueryForMagistratesITmulti-page count still green).ouCoderouting is deliberately left unchanged (deferred; the retained routing coupling is documented in ADR-006 §6).Tests
RangeSearchQueryTest, +2, written test-first RED→GREEN): per-day split + draft exclusion. Full class 33/33.RangeSearchQueryForCourtCalendarIT, +1):crownCourtSchedulerPathKeepsEachHearingDayDistinctdrives PATH A end-to-end for CROWN. Full listing IT suite run locally: 257 passed, 0 failures, 0 errors (3 pre-existing skips);RangeSearchQueryForMagistratesITstill green.CourtSchedulerServiceStub.stubGetHearingIdsWithBody(...).Verification
mvn clean+./runIntegrationTests.shfull suite: BUILD SUCCESS, 257/257.context-verifyCI pipeline on this PR.Ticket: SPRDT-1164