Skip to content

Commit

Permalink
PI-2530 - order events by created date (#4240)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj authored Sep 17, 2024
1 parent b21ff8e commit c1a72e0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ object PersonGenerator {
active = active,
mainOffence = mainOffence,
notes = notes,
additionalOffences = additionalOffences
additionalOffences = additionalOffences,
dateCreated = ZonedDateTime.now()
)

val DISABILITIES: List<Disability> = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ class SentenceIntegrationTest {
val expected = SentenceOverview(
PersonGenerator.OVERVIEW.toSummary(),
listOf(
Sentence(
OffenceDetails(
"1234567",
Offence("Another Murder", 1),
LocalDate.now(),
"overview",
emptyList()
),
Conviction(null, null, null, listOf()),
null,
listOf(),
listOf(),
null
),
Sentence(
OffenceDetails(
"7654321",
Expand Down Expand Up @@ -101,20 +115,6 @@ class SentenceIntegrationTest {
CourtDocument(EVENT_DOCUMENT.alfrescoId, LocalDate.now().minusDays(3), "event report")
),
"3 minutes completed (of 12 hours)"
),
Sentence(
OffenceDetails(
"1234567",
Offence("Another Murder", 1),
LocalDate.now(),
"overview",
emptyList()
),
Conviction(null, null, null, listOf()),
null,
listOf(),
listOf(),
null
)
),
ProbationHistory(2, LocalDate.now().minusDays(7), 2, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.Court
import java.time.LocalDate
import java.time.ZonedDateTime

@Immutable
@Entity
Expand Down Expand Up @@ -50,7 +51,10 @@ class Event(
val notes: String?,

@Column(columnDefinition = "number")
val softDeleted: Boolean = false
val softDeleted: Boolean = false,

@Column(name = "created_datetime")
val dateCreated: ZonedDateTime,
)

interface EventRepository : JpaRepository<Event, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface EventSentenceRepository : JpaRepository<Event, Long> {
"LEFT JOIN FETCH m.offence mo " +
"LEFT JOIN FETCH ao.offence aoo " +
"WHERE e.personId = :id " +
"ORDER BY e.eventNumber DESC "
"ORDER BY e.dateCreated DESC "
)
fun findSentencesByPersonId(id: Long): List<Event>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.PersonRe
import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.RequirementRepository
import uk.gov.justice.digital.hmpps.utils.Summary
import java.time.LocalDate
import java.time.ZonedDateTime

@ExtendWith(MockitoExtension::class)
internal class ComplianceServiceTest {
Expand Down Expand Up @@ -72,7 +73,8 @@ internal class ComplianceServiceTest {
personId = OVERVIEW.id,
convictionDate = LocalDate.now(),
inBreach = false,
notes = ""
notes = "",
dateCreated = ZonedDateTime.now()
),
Event(
id = BREACH_PREVIOUS_ORDER_2.eventId ?: 0,
Expand All @@ -83,7 +85,8 @@ internal class ComplianceServiceTest {
personId = OVERVIEW.id,
convictionDate = LocalDate.now(),
inBreach = false,
notes = ""
notes = "",
dateCreated = ZonedDateTime.now()
),
Event(
id = 3,
Expand All @@ -95,7 +98,8 @@ internal class ComplianceServiceTest {
personId = OVERVIEW.id,
convictionDate = LocalDate.now(),
inBreach = false,
notes = ""
notes = "",
dateCreated = ZonedDateTime.now()
),
Event(
id = 4,
Expand All @@ -107,7 +111,8 @@ internal class ComplianceServiceTest {
personId = OVERVIEW.id,
convictionDate = LocalDate.now(),
inBreach = false,
notes = ""
notes = "",
dateCreated = ZonedDateTime.now()
),
)

Expand Down

0 comments on commit c1a72e0

Please sign in to comment.