Skip to content

Commit

Permalink
PI-2543 Deploy UPW appointments API (#4341)
Browse files Browse the repository at this point in the history
* PI-2543 Deploy UPW appointments API

* Fix repository method
  • Loading branch information
marcus-bcl authored Oct 24, 2024
1 parent 5795b17 commit 40cc317
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enabled: false # TODO set this to true when you're ready to deploy your service

generic-service:
ingress:
host: appointment-reminders-and-delius-dev.hmpps.service.justice.gov.uk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enabled: false # TODO set this to true when you're ready to deploy your service

generic-service:
ingress:
host: appointment-reminders-and-delius-preprod.hmpps.service.justice.gov.uk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ internal class IntegrationTest {
fun `returns csv report`() {
whenever(upwAppointmentRepository.getUnpaidWorkAppointments(any(), eq("N56"), any())).thenReturn(
listOf(
UnpaidWorkAppointment(
crn = "A123456",
firstName = "Test",
mobileNumber = "07000000000",
appointmentDate = "01/01/2000",
appointmentTimes = "08:00, 11:00",
nextWorkSessionProjectType = "Group session",
today = "01/01/2000",
sendSmsForDay = "01/01/2000",
fullName = "Test Test",
numberOfEvents = "1",
activeUpwRequirements = "1",
custodialStatus = null,
currentRemandStatus = null,
allowSms = "Y",
originalMobileNumber = "070 0000 0000",
upwMinutesRemaining = "123"
)
object : UnpaidWorkAppointment {
override val crn = "A123456"
override val firstName = "Test"
override val mobileNumber = "07000000000"
override val appointmentDate = "01/01/2000"
override val appointmentTimes = "08:00, 11:00"
override val nextWorkSessionProjectType = "Group session"
override val today = "01/01/2000"
override val sendSmsForDay = "01/01/2000"
override val fullName = "Test Test"
override val numberOfEvents = "1"
override val activeUpwRequirements = "1"
override val custodialStatus = null
override val currentRemandStatus = null
override val allowSms = "Y"
override val originalMobileNumber = "070 0000 0000"
override val upwMinutesRemaining = "123"
}
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder
"originalMobileNumber",
"upwMinutesRemaining"
)
data class UnpaidWorkAppointment(
val crn: String,
val firstName: String,
val mobileNumber: String,
val appointmentDate: String,
val appointmentTimes: String,
val nextWorkSessionProjectType: String,
val today: String,
val sendSmsForDay: String,
val fullName: String,
val numberOfEvents: String,
val activeUpwRequirements: String,
val custodialStatus: String?,
val currentRemandStatus: String?,
val allowSms: String,
val originalMobileNumber: String,
interface UnpaidWorkAppointment {
val crn: String
val firstName: String
val mobileNumber: String
val appointmentDate: String
val appointmentTimes: String
val nextWorkSessionProjectType: String
val today: String
val sendSmsForDay: String
val fullName: String
val numberOfEvents: String
val activeUpwRequirements: String
val custodialStatus: String?
val currentRemandStatus: String?
val allowSms: String
val originalMobileNumber: String
val upwMinutesRemaining: String
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ interface UpwAppointmentRepository : JpaRepository<UpwAppointment, Long> {
@Query(
"""
select
crn,
any_value(first_name) as first_name,
any_value(mobile_number) as mobile_number,
any_value(to_char(appointment_date_time, 'DD/MM/YYYY')) as appointment_date,
listagg(distinct to_char(appointment_date_time, 'HH24:MI'), ', ') as appointment_times,
listagg(distinct next_work_session_project_type, ', ') as next_work_session_project_type,
to_char(current_date, 'DD/MM/YYYY') as today,
to_char(:date, 'DD/MM/YYYY') as send_sms_for_day,
any_value(full_name) as full_name,
count(distinct event_number) as number_of_events,
listagg(distinct active_upw_requirements, ', ') as active_upw_requirements,
listagg(distinct custodial_status, ', ') as custodial_status,
any_value(current_remand_status) as current_remand_status,
any_value(allow_sms) as allow_sms,
any_value(original_mobile_number) as original_mobile_number,
listagg(distinct upw_minutes_remaining, ', ') as upw_minutes_remaining
crn as "crn",
any_value(first_name) as "firstName",
any_value(mobile_number) as "mobileNumber",
any_value(to_char(appointment_date_time, 'DD/MM/YYYY')) as "appointmentDate",
listagg(distinct to_char(appointment_date_time, 'HH24:MI'), ', ') as "appointmentTimes",
listagg(distinct next_work_session_project_type, ', ') as "nextWorkSessionProjectType",
to_char(current_date, 'DD/MM/YYYY') as "today",
to_char(:date, 'DD/MM/YYYY') as "sendSmsForDay",
any_value(full_name) as "fullName",
count(distinct event_number) as "numberOfEvents",
listagg(distinct active_upw_requirements, ', ') as "activeUpwRequirements",
listagg(distinct custodial_status, ', ') as "custodialStatus",
any_value(current_remand_status) as "currentRemandStatus",
any_value(allow_sms) as "allowSms",
any_value(original_mobile_number) as "originalMobileNumber",
listagg(distinct upw_minutes_remaining, ', ') as "upwMinutesRemaining"
from (
with duplicate_mobile_numbers as (
select offender.offender_id from offender
Expand Down

0 comments on commit 40cc317

Please sign in to comment.