Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occupancy View - add license expiry date to matching details section #2263

Merged

Conversation

gregkhawkins
Copy link
Contributor

Context

  • This relates to this ticket: https://dsdmoj.atlassian.net/browse/APS-1624
  • We previously de-scoped including the Licence expiry date data from the Matching details section on the Occupancy View page because the data was not available from the API
  • The Licence expiry date data has since been made available from the GET /placement-requests/{id} API endpoint

Changes in this PR

  • Add the Licence expiry date data into the Matching details section on the Occupancy View

Screenshots of UI changes

Before

before

After

after

Copy link
Contributor

@bobmeredith bobmeredith left a comment

Choose a reason for hiding this comment

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

Looks good.
A couple of comments.

Has there been an API change to return the whole application along with a placement request? If so, that doesn't sound like a good thing from a performance POV. The page controller could always get the application in a separate call if needed.

@@ -32,7 +31,7 @@ export default class OccupancyViewPage extends Page {
totalCapacity: number,
startDate: string,
durationDays: number,
placementRequest: PlacementRequest,
placementRequest: PlacementRequestDetail,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the switch?
Does this mean that the entire Application is now returned along with the placement request in placementRequestService.getPlacementRequest()
That seems like a performance hit as there will be many places where the application is not needed.

Copy link
Contributor Author

@gregkhawkins gregkhawkins Dec 20, 2024

Choose a reason for hiding this comment

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

thanks for looking at this @bobmeredith was half expecting this to be an after xmas review. Appreciate it :)

So, in this test code, this function goes on to call the occupancyViewSummaryListForMatchingDetails() function to assert some expectations. To achieve this it needs to pass the correct type - which has changed because of the data-type change late on in the PR:
https://github.com/ministryofjustice/hmpps-approved-premises-ui/pull/2263/files#diff-cc8326f12e1aed4a0d54a6c3199c6dac2af0450fec3103000188aa31f6df42cb

The justification for that data type change is that, in actual fact, we have always been passing an object of type PlacementRequestDetail into that function but the data type was set incorrectly to it's parent type (i.e. PlacementRequest). It wasn't flagging issues (as we were passing a child of that parent) but the change is now needed so I can access the application from the PlacementRequestDetail (so i can go on to grab the licenceExpiryDate later).

Furthermore, in the occupancy view controller, we make the below call:

placement-request-detail-call

As you can see above, from the IDE hint, what we get back has always been of type PlacementRequestDetail (not PlacementRequest). And back to the test:
here

As you can see we were always stubbing PlacementRequestDetail (not the parent PlacementRequest) which is why there are no side effects of this data type change also

managerDetails: string,
): Array<SummaryListItem> => {
const placementRequestDates = placementDates(placementRequest.expectedArrival, placementRequest.duration)
const essentialCharacteristics = filterOutAPTypes(placementRequest.essentialCriteria)
const application = placementRequest.application as ApprovedPremisesApplication
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to check the type, or can we guarantee that this Application is always an ApprovedPremisesApplication

Copy link
Contributor Author

@gregkhawkins gregkhawkins Dec 20, 2024

Choose a reason for hiding this comment

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

I had a quick look into the BE code and saw that when we hit the GET /placement-requests/{id} endpoint, it essentially goes off and build the placement request including the application. To build the correct application type it executes this code:
Screenshot 2024-12-20 at 15 00 23 (2)

So, the is stuff above determines which application type is attached to this placement request and builds it up accordingly. My understanding is that in this area (i.e. Occupancy view) the placements requests will all be of type ApprovedPremisesApplicationEntity as this Occupancy view area is functionality used for CAS1 applications only. Let me know if this is wrong! If not wrong, conclusion is yes we can guarantee that this Application is always an ApprovedPremisesApplication.

Let me know if I'm missing anything :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. I appreciate it!

@gregkhawkins
Copy link
Contributor Author

gregkhawkins commented Dec 20, 2024

Thanks again for the review!
Re Has there been an API change to return the whole application along with a placement request? As touched on above the BE is returning the whole application and looking at the BE git history it has been returning the application for a while.
Perhaps this is one to raise as a refactor if we want a BE dev ticket split into two calls instead? May of course have side effects that may need investigating, but also worth flagging if we are worried about performance implications

Copy link
Contributor

@bobmeredith bobmeredith left a comment

Choose a reason for hiding this comment

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

OK, well in that case LGTM.
I do think we should look to refactor as large unnecessary payloads are not a good thing.

@gregkhawkins gregkhawkins force-pushed the feature/APS-1624__occupancy_view_add_license_expiry_date branch from cb3dbfa to fc9382d Compare December 30, 2024 10:05
@gregkhawkins gregkhawkins merged commit 52bc71f into main Dec 30, 2024
7 checks passed
@gregkhawkins gregkhawkins deleted the feature/APS-1624__occupancy_view_add_license_expiry_date branch December 30, 2024 10:21
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