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

APS-1745 remove unused space search fields #2736

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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#
Expand Down Expand Up @@ -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"),
Expand All @@ -154,7 +140,6 @@ class Cas1SpaceSearchRepository(
rs.getString("postcode"),
rs.getUUID("ap_area_id"),
rs.getString("ap_area_name"),
rs.getInt("total_spaces_count"),
)
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,7 +29,6 @@ class Cas1SpaceSearchResultsTransformer {
id = candidatePremises.apAreaId,
name = candidatePremises.apAreaName,
),
totalSpaceCount = candidatePremises.totalSpaceCount,
premisesCharacteristics = listOf(),
),
distanceInMiles = candidatePremises.distanceInMiles.toBigDecimal(),
Expand Down
10 changes: 0 additions & 10 deletions src/main/resources/static/cas1-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions src/main/resources/static/codegen/built-cas1-api-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class Cas1SpaceSearchServiceTest {
val candidatePremises1 = CandidatePremises(
UUID.randomUUID(),
1.0f,
"AP1234",
"QCODE1",
ApprovedPremisesType.NORMAL,
"Some AP",
"1 The Street",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -126,7 +118,6 @@ class Cas1SpaceSearchServiceTest {
"TB1 2AB",
UUID.randomUUID(),
"Some AP Area",
9,
)

val spaceCharacteristics = Cas1SpaceCharacteristic.entries.map { characteristicWithRandomModelScopeCalled(it.value) }
Expand Down Expand Up @@ -200,8 +191,6 @@ class Cas1SpaceSearchServiceTest {
val candidatePremises1 = CandidatePremises(
UUID.randomUUID(),
1.0f,
"AP1234",
"QCODE1",
ApprovedPremisesType.NORMAL,
"Some AP",
"1 The Street",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -242,7 +225,6 @@ class Cas1SpaceSearchServiceTest {
"TB1 2AB",
UUID.randomUUID(),
"Some AP Area",
9,
)

val spaceCharacteristics = Cas1SpaceCharacteristic.entries.map { characteristicWithRandomModelScopeCalled(it.value) }
Expand Down Expand Up @@ -308,8 +290,6 @@ class Cas1SpaceSearchServiceTest {
val candidatePremises1 = CandidatePremises(
UUID.randomUUID(),
1.0f,
"AP1234",
"QCODE1",
ApprovedPremisesType.NORMAL,
"Some AP",
"1 The Street",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -350,7 +324,6 @@ class Cas1SpaceSearchServiceTest {
"TB1 2AB",
UUID.randomUUID(),
"Some AP Area",
9,
)

val spaceCharacteristics = Cas1SpaceCharacteristic.entries.map { characteristicWithRandomModelScopeCalled(it.value) }
Expand Down Expand Up @@ -415,8 +388,6 @@ class Cas1SpaceSearchServiceTest {
val candidatePremises1 = CandidatePremises(
UUID.randomUUID(),
1.0f,
"AP1234",
"QCODE1",
ApprovedPremisesType.NORMAL,
"Some AP",
"1 The Street",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -457,7 +422,6 @@ class Cas1SpaceSearchServiceTest {
"TB1 2AB",
UUID.randomUUID(),
"Some AP Area",
9,
)

val spaceCharacteristicEntities = spaceCharacteristics.map { characteristicWithRandomModelScopeCalled(it.value) }
Expand Down
Loading
Loading