diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/repository/MatchRepository.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/repository/MatchRepository.kt index c13283e..9af71f2 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/repository/MatchRepository.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/repository/MatchRepository.kt @@ -5,7 +5,6 @@ import org.springframework.data.jpa.repository.Query import org.springframework.data.repository.query.Param import org.springframework.stereotype.Repository import uk.gov.justice.digital.hmpps.learnerrecordsapi.models.db.MatchEntity -import java.time.LocalDate import java.time.LocalDateTime @Repository @@ -15,19 +14,17 @@ interface MatchRepository : JpaRepository { nomisId: String, ): MatchEntity? - fun findAllByNomisId(nomisId: String): List - @Query( """ SELECT m FROM MatchEntity m WHERE m.nomisId = :nomisId AND (:fromDate IS NULL OR m.dateCreated >= :fromDate) AND (:toDate IS NULL OR m.dateCreated <= :toDate) - """ + """, ) fun findForSubjectAccessRequest( @Param("nomisId") nomisId: String, @Param("fromDate") fromDate: LocalDateTime?, - @Param("toDate") toDate: LocalDateTime? + @Param("toDate") toDate: LocalDateTime?, ): List } diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/service/MatchService.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/service/MatchService.kt index 9847645..03ec170 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/service/MatchService.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/service/MatchService.kt @@ -30,11 +30,13 @@ class MatchService( return matchRepository.save(entity).id } - fun getDataForSubjectAccessRequest(nomisId: String, fromDate: LocalDate?, toDate: LocalDate?): List { - return matchRepository.findForSubjectAccessRequest( - nomisId, - fromDate?.atStartOfDay(), - toDate?.plusDays(1)?.atStartOfDay()?.minusNanos(1L) - ) - } + fun getDataForSubjectAccessRequest( + nomisId: String, + fromDate: LocalDate?, + toDate: LocalDate?, + ): List = matchRepository.findForSubjectAccessRequest( + nomisId, + fromDate?.atStartOfDay(), + toDate?.plusDays(1)?.atStartOfDay()?.minusNanos(1L), + ) } diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/integration/SubjectAccessRequestSampleIntegrationTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/integration/SubjectAccessRequestSampleIntegrationTest.kt index c0f4abe..8abedf3 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/integration/SubjectAccessRequestSampleIntegrationTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/learnerrecordsapi/integration/SubjectAccessRequestSampleIntegrationTest.kt @@ -104,4 +104,4 @@ class SubjectAccessRequestIntegrationTest : IntegrationTestBase() { } } -// Try using the old code, with the param fixed \ No newline at end of file +// Try using the old code, with the param fixed