-
Notifications
You must be signed in to change notification settings - Fork 1
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
Occupancy View - add license expiry date to matching details section #2263
Conversation
There was a problem hiding this 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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
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:
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
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 :)
There was a problem hiding this comment.
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!
Thanks again for the review! |
There was a problem hiding this 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.
cb3dbfa
to
fc9382d
Compare
Context
Licence expiry date
data from theMatching details
section on theOccupancy View
page because the data was not available from the APILicence expiry date
data has since been made available from theGET /placement-requests/{id}
API endpointChanges in this PR
Licence expiry date
data into theMatching details
section on theOccupancy View
Screenshots of UI changes
Before
After