From 0fb9dde2d3693a34932726bbe39b0327f2c8eedd Mon Sep 17 00:00:00 2001 From: davidatkinsuk Date: Fri, 20 Dec 2024 10:58:39 +0000 Subject: [PATCH] Remove unused space search result fields --- .../cas1/Cas1PremisesSearchRepository.kt | 30 +++------------- .../Cas1SeedPremisesFromSiteSurveyXlsxJob.kt | 2 +- .../cas1/Cas1SpaceSearchResultsTransformer.kt | 3 -- src/main/resources/static/cas1-schemas.yml | 10 ------ .../static/codegen/built-cas1-api-spec.yml | 10 ------ .../integration/cas1/Cas1SpaceSearchTest.kt | 6 ---- .../cas1/Cas1SpaceSearchServiceTest.kt | 36 ------------------- .../Cas1SpaceSearchResultsTransformerTest.kt | 12 ------- 8 files changed, 5 insertions(+), 104 deletions(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/jpa/entity/cas1/Cas1PremisesSearchRepository.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/jpa/entity/cas1/Cas1PremisesSearchRepository.kt index f8e837f705..f09d644f27 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/jpa/entity/cas1/Cas1PremisesSearchRepository.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/jpa/entity/cas1/Cas1PremisesSearchRepository.kt @@ -42,8 +42,6 @@ FROM (SELECT point FROM postcode_districts pd WHERE pd.outcode = :outcode)::geography, ap.point::geography ) * 0.000621371 AS distance_in_miles, - ap.ap_code AS ap_code, - ap.q_code AS delius_q_code, CASE WHEN EXISTS ( SELECT 1 @@ -89,21 +87,11 @@ FROM p.town AS town, p.postcode AS postcode, aa.id AS ap_area_id, - aa.name AS ap_area_name, - ( - SELECT COUNT(*) - FROM beds b - JOIN rooms r - ON b.room_id = r.id - WHERE r.premises_id = p.id - ) AS total_spaces_count + aa.name AS ap_area_name FROM approved_premises ap - JOIN premises p - ON ap.premises_id = p.id - JOIN probation_regions pr - ON p.probation_region_id = pr.id - JOIN ap_areas aa - ON pr.ap_area_id = aa.id + INNER JOIN premises p ON ap.premises_id = p.id + INNER JOIN probation_regions pr ON p.probation_region_id = pr.id + INNER JOIN ap_areas aa ON pr.ap_area_id = aa.id WHERE ap.supports_space_bookings = true AND ap.gender = #SPECIFIED_GENDER# @@ -144,8 +132,6 @@ class Cas1SpaceSearchRepository( CandidatePremises( rs.getUUID("premises_id"), rs.getFloat("distance_in_miles"), - rs.getString("ap_code"), - rs.getString("delius_q_code"), apType, rs.getString("name"), rs.getString("address_line1"), @@ -154,7 +140,6 @@ class Cas1SpaceSearchRepository( rs.getString("postcode"), rs.getUUID("ap_area_id"), rs.getString("ap_area_name"), - rs.getInt("total_spaces_count"), ) } } @@ -230,8 +215,6 @@ class Cas1SpaceSearchRepository( data class CandidatePremises( val premisesId: UUID, val distanceInMiles: Float, - val apCode: String, - val deliusQCode: String, val apType: ApprovedPremisesType, val name: String, val addressLine1: String, @@ -240,9 +223,4 @@ data class CandidatePremises( val postcode: String, val apAreaId: UUID, val apAreaName: String, - val totalSpaceCount: Int, -) - -data class SpaceAvailability( - val premisesId: UUID, ) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/seed/cas1/Cas1SeedPremisesFromSiteSurveyXlsxJob.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/seed/cas1/Cas1SeedPremisesFromSiteSurveyXlsxJob.kt index c4240f4968..a7584bc98f 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/seed/cas1/Cas1SeedPremisesFromSiteSurveyXlsxJob.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/seed/cas1/Cas1SeedPremisesFromSiteSurveyXlsxJob.kt @@ -192,7 +192,7 @@ class Cas1SeedPremisesFromSiteSurveyXlsxJob( val diff = javers.compare(beforeChange, afterChange) if (diff.hasChanges()) { - log.info("Changes are ${diff.prettyPrint()}") + log.info("Changes for import of ${siteSurvey.name} are ${diff.prettyPrint()}") premisesRepository.save(existingPremise) } else { entityManager.clear() diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/cas1/Cas1SpaceSearchResultsTransformer.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/cas1/Cas1SpaceSearchResultsTransformer.kt index 942583b31a..07ec5cf6d6 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/cas1/Cas1SpaceSearchResultsTransformer.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/cas1/Cas1SpaceSearchResultsTransformer.kt @@ -19,8 +19,6 @@ class Cas1SpaceSearchResultsTransformer { ApiSpaceSearchResult( premises = Cas1PremisesSearchResultSummary( id = candidatePremises.premisesId, - apCode = candidatePremises.apCode, - deliusQCode = candidatePremises.deliusQCode, apType = candidatePremises.apType.asApiType(), name = candidatePremises.name, addressLine1 = candidatePremises.addressLine1, @@ -31,7 +29,6 @@ class Cas1SpaceSearchResultsTransformer { id = candidatePremises.apAreaId, name = candidatePremises.apAreaName, ), - totalSpaceCount = candidatePremises.totalSpaceCount, premisesCharacteristics = listOf(), ), distanceInMiles = candidatePremises.distanceInMiles.toBigDecimal(), diff --git a/src/main/resources/static/cas1-schemas.yml b/src/main/resources/static/cas1-schemas.yml index 1849616d37..3613dcb0b7 100644 --- a/src/main/resources/static/cas1-schemas.yml +++ b/src/main/resources/static/cas1-schemas.yml @@ -31,12 +31,6 @@ components: id: type: string format: uuid - apCode: - type: string - example: NEHOPE1 - deliusQCode: - type: string - example: Q005 apType: $ref: '_shared.yml#/components/schemas/ApType' name: @@ -56,10 +50,6 @@ components: example: LS1 3AD apArea: $ref: '_shared.yml#/components/schemas/NamedId' - totalSpaceCount: - type: integer - description: The total number of spaces in this premises - example: 22 premisesCharacteristics: type: array items: diff --git a/src/main/resources/static/codegen/built-cas1-api-spec.yml b/src/main/resources/static/codegen/built-cas1-api-spec.yml index b916a34025..294bff0ee1 100644 --- a/src/main/resources/static/codegen/built-cas1-api-spec.yml +++ b/src/main/resources/static/codegen/built-cas1-api-spec.yml @@ -6081,12 +6081,6 @@ components: id: type: string format: uuid - apCode: - type: string - example: NEHOPE1 - deliusQCode: - type: string - example: Q005 apType: $ref: '#/components/schemas/ApType' name: @@ -6106,10 +6100,6 @@ components: example: LS1 3AD apArea: $ref: '#/components/schemas/NamedId' - totalSpaceCount: - type: integer - description: The total number of spaces in this premises - example: 22 premisesCharacteristics: type: array items: diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/cas1/Cas1SpaceSearchTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/cas1/Cas1SpaceSearchTest.kt index 13e6ec3713..b1bd790ad8 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/cas1/Cas1SpaceSearchTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/cas1/Cas1SpaceSearchTest.kt @@ -321,18 +321,12 @@ class Cas1SpaceSearchTest : InitialiseDatabasePerClassTestBase() { assertThat(actual.distanceInMiles).isGreaterThan(0f.toBigDecimal()) assertThat(actual.premises).isNotNull assertThat(actual.premises!!.id).isEqualTo(expected.id) - assertThat(actual.premises!!.apCode).isEqualTo(expected.apCode) - assertThat(actual.premises!!.deliusQCode).isEqualTo(expected.qCode) assertThat(actual.premises!!.apType).isEqualTo(expectedApType) assertThat(actual.premises!!.name).isEqualTo(expected.name) assertThat(actual.premises!!.addressLine1).isEqualTo(expected.addressLine1) assertThat(actual.premises!!.addressLine2).isEqualTo(expected.addressLine2) assertThat(actual.premises!!.town).isEqualTo(expected.town) assertThat(actual.premises!!.postcode).isEqualTo(expected.postcode) - assertThat(actual.premises!!.apArea).isNotNull - assertThat(actual.premises!!.apArea!!.id).isEqualTo(expected.probationRegion.apArea!!.id) - assertThat(actual.premises!!.apArea!!.name).isEqualTo(expected.probationRegion.apArea!!.name) - assertThat(actual.premises!!.totalSpaceCount).isEqualTo(expected.rooms.flatMap { it.beds }.count()) assertThat(actual.premises!!.premisesCharacteristics).isEmpty() } diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/service/cas1/Cas1SpaceSearchServiceTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/service/cas1/Cas1SpaceSearchServiceTest.kt index 134e747c30..caeacd7b0a 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/service/cas1/Cas1SpaceSearchServiceTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/service/cas1/Cas1SpaceSearchServiceTest.kt @@ -84,8 +84,6 @@ class Cas1SpaceSearchServiceTest { val candidatePremises1 = CandidatePremises( UUID.randomUUID(), 1.0f, - "AP1234", - "QCODE1", ApprovedPremisesType.NORMAL, "Some AP", "1 The Street", @@ -94,14 +92,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 3, ) val candidatePremises2 = CandidatePremises( UUID.randomUUID(), 2.0f, - "AP2345", - "QCODE2", ApprovedPremisesType.ESAP, "Some Other AP", "2 The Street", @@ -110,14 +105,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 6, ) val candidatePremises3 = CandidatePremises( UUID.randomUUID(), 3.0f, - "AP3456", - "QCODE3", ApprovedPremisesType.PIPE, "Some AP", "3 The Street", @@ -126,7 +118,6 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 9, ) val spaceCharacteristics = Cas1SpaceCharacteristic.entries.map { characteristicWithRandomModelScopeCalled(it.value) } @@ -200,8 +191,6 @@ class Cas1SpaceSearchServiceTest { val candidatePremises1 = CandidatePremises( UUID.randomUUID(), 1.0f, - "AP1234", - "QCODE1", ApprovedPremisesType.NORMAL, "Some AP", "1 The Street", @@ -210,14 +199,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 3, ) val candidatePremises2 = CandidatePremises( UUID.randomUUID(), 2.0f, - "AP2345", - "QCODE2", ApprovedPremisesType.ESAP, "Some Other AP", "2 The Street", @@ -226,14 +212,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 6, ) val candidatePremises3 = CandidatePremises( UUID.randomUUID(), 3.0f, - "AP3456", - "QCODE3", ApprovedPremisesType.PIPE, "Some AP", "3 The Street", @@ -242,7 +225,6 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 9, ) val spaceCharacteristics = Cas1SpaceCharacteristic.entries.map { characteristicWithRandomModelScopeCalled(it.value) } @@ -308,8 +290,6 @@ class Cas1SpaceSearchServiceTest { val candidatePremises1 = CandidatePremises( UUID.randomUUID(), 1.0f, - "AP1234", - "QCODE1", ApprovedPremisesType.NORMAL, "Some AP", "1 The Street", @@ -318,14 +298,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 3, ) val candidatePremises2 = CandidatePremises( UUID.randomUUID(), 2.0f, - "AP2345", - "QCODE2", ApprovedPremisesType.ESAP, "Some Other AP", "2 The Street", @@ -334,14 +311,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 6, ) val candidatePremises3 = CandidatePremises( UUID.randomUUID(), 3.0f, - "AP3456", - "QCODE3", ApprovedPremisesType.PIPE, "Some AP", "3 The Street", @@ -350,7 +324,6 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 9, ) val spaceCharacteristics = Cas1SpaceCharacteristic.entries.map { characteristicWithRandomModelScopeCalled(it.value) } @@ -415,8 +388,6 @@ class Cas1SpaceSearchServiceTest { val candidatePremises1 = CandidatePremises( UUID.randomUUID(), 1.0f, - "AP1234", - "QCODE1", ApprovedPremisesType.NORMAL, "Some AP", "1 The Street", @@ -425,14 +396,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 3, ) val candidatePremises2 = CandidatePremises( UUID.randomUUID(), 2.0f, - "AP2345", - "QCODE2", ApprovedPremisesType.ESAP, "Some Other AP", "2 The Street", @@ -441,14 +409,11 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 6, ) val candidatePremises3 = CandidatePremises( UUID.randomUUID(), 3.0f, - "AP3456", - "QCODE3", ApprovedPremisesType.PIPE, "Some AP", "3 The Street", @@ -457,7 +422,6 @@ class Cas1SpaceSearchServiceTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 9, ) val spaceCharacteristicEntities = spaceCharacteristics.map { characteristicWithRandomModelScopeCalled(it.value) } diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/cas1/Cas1SpaceSearchResultsTransformerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/cas1/Cas1SpaceSearchResultsTransformerTest.kt index b8cb2c3b05..0ab886161d 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/cas1/Cas1SpaceSearchResultsTransformerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/cas1/Cas1SpaceSearchResultsTransformerTest.kt @@ -35,8 +35,6 @@ class Cas1SpaceSearchResultsTransformerTest { val candidatePremises1 = CandidatePremises( UUID.randomUUID(), 1.0f, - "AP1234", - "QCODE1", ApprovedPremisesType.NORMAL, "Some AP", "1 The Street", @@ -45,14 +43,11 @@ class Cas1SpaceSearchResultsTransformerTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 3, ) val candidatePremises2 = CandidatePremises( UUID.randomUUID(), 2.0f, - "AP2345", - "QCODE2", ApprovedPremisesType.NORMAL, "Some Other AP", "2 The Street", @@ -61,14 +56,11 @@ class Cas1SpaceSearchResultsTransformerTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 6, ) val candidatePremises3 = CandidatePremises( UUID.randomUUID(), 3.0f, - "AP3456", - "QCODE3", ApprovedPremisesType.NORMAL, "Some AP", "3 The Street", @@ -77,7 +69,6 @@ class Cas1SpaceSearchResultsTransformerTest { "TB1 2AB", UUID.randomUUID(), "Some AP Area", - 9, ) val searchResults = listOf( @@ -98,8 +89,6 @@ class Cas1SpaceSearchResultsTransformerTest { private fun assertThatTransformedResultMatches(actual: ApiSpaceSearchResult, expected: CandidatePremises) { assertThat(actual.premises).isNotNull assertThat(actual.premises!!.id).isEqualTo(expected.premisesId) - assertThat(actual.premises!!.apCode).isEqualTo(expected.apCode) - assertThat(actual.premises!!.deliusQCode).isEqualTo(expected.deliusQCode) assertThat(actual.premises!!.apType).isEqualTo(expected.apType.asApiType()) assertThat(actual.premises!!.name).isEqualTo(expected.name) assertThat(actual.premises!!.addressLine1).isEqualTo(expected.addressLine1) @@ -109,7 +98,6 @@ class Cas1SpaceSearchResultsTransformerTest { assertThat(actual.premises!!.apArea).isNotNull assertThat(actual.premises!!.apArea!!.id).isEqualTo(expected.apAreaId) assertThat(actual.premises!!.apArea!!.name).isEqualTo(expected.apAreaName) - assertThat(actual.premises!!.totalSpaceCount).isEqualTo(expected.totalSpaceCount) assertThat(actual.premises!!.premisesCharacteristics).isEmpty() assertThat(actual.distanceInMiles).isEqualTo(expected.distanceInMiles.toBigDecimal()) assertThat(actual.spacesAvailable).isEmpty()