Skip to content

Commit

Permalink
PI-2621 Exclude breach / recall dates linked to inactive events (#4400)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl authored Nov 7, 2024
1 parent 5da437f commit edf1ff5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Nsi(
@Column(name = "nsi_id")
val id: Long = 0,

val eventId: Long? = null,

@Column(name = "active_flag", columnDefinition = "number")
var active: Boolean = true,

Expand All @@ -45,27 +47,30 @@ interface NsiRepository : JpaRepository<Nsi, Long> {
with latest_breach as (select nsi.referral_date as breachdate
from nsi nsi
join r_nsi_type ref on nsi.nsi_type_id = ref.nsi_type_id
left join event on event.event_id = nsi.event_id
where nsi.offender_id = :personId
and (event.event_id is null or (event.active_flag = 1 and event.soft_deleted = 0))
and nsi.active_flag = 1
and nsi.soft_deleted = 0
and ref.code = 'BRE'
order by nsi.referral_date desc
fetch next 1 row only),
latest_recall as (select nsi.referral_date as recalldate
from nsi nsi
join r_nsi_type ref
on nsi.nsi_type_id = ref.nsi_type_id
where nsi.offender_id = :personId
and nsi.active_flag = 1
and nsi.soft_deleted = 0
and ref.code = 'REC'
order by nsi.referral_date desc
fetch next 1 row only)
from nsi nsi
join r_nsi_type ref on nsi.nsi_type_id = ref.nsi_type_id
left join event on event.event_id = nsi.event_id
where nsi.offender_id = :personId
and (event.event_id is null or (event.active_flag = 1 and event.soft_deleted = 0))
and nsi.active_flag = 1
and nsi.soft_deleted = 0
and ref.code = 'REC'
order by nsi.referral_date desc
fetch next 1 row only)
select breachdate as referralDate, 'breach' as name
from latest_breach
union all
select recalldate as referralDate, 'recall' as name
from latest_recall
from latest_recall
""",
nativeQuery = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Nsi(
@Column(name = "nsi_id")
val id: Long = 0,

val eventId: Long? = null,

@Column(name = "active_flag", columnDefinition = "number")
var active: Boolean = true,

Expand All @@ -45,27 +47,30 @@ interface NsiRepository : JpaRepository<Nsi, Long> {
with latest_breach as (select nsi.referral_date as breachdate
from nsi nsi
join r_nsi_type ref on nsi.nsi_type_id = ref.nsi_type_id
left join event on event.event_id = nsi.event_id
where nsi.offender_id = :personId
and (event.event_id is null or (event.active_flag = 1 and event.soft_deleted = 0))
and nsi.active_flag = 1
and nsi.soft_deleted = 0
and ref.code = 'BRE'
order by nsi.referral_date desc
fetch next 1 row only),
latest_recall as (select nsi.referral_date as recalldate
from nsi nsi
join r_nsi_type ref
on nsi.nsi_type_id = ref.nsi_type_id
where nsi.offender_id = :personId
and nsi.active_flag = 1
and nsi.soft_deleted = 0
and ref.code = 'REC'
order by nsi.referral_date desc
fetch next 1 row only)
from nsi nsi
join r_nsi_type ref on nsi.nsi_type_id = ref.nsi_type_id
left join event on event.event_id = nsi.event_id
where nsi.offender_id = :personId
and (event.event_id is null or (event.active_flag = 1 and event.soft_deleted = 0))
and nsi.active_flag = 1
and nsi.soft_deleted = 0
and ref.code = 'REC'
order by nsi.referral_date desc
fetch next 1 row only)
select breachdate as referralDate, 'breach' as name
from latest_breach
union all
select recalldate as referralDate, 'recall' as name
from latest_recall
from latest_recall
""",
nativeQuery = true
)
Expand Down

0 comments on commit edf1ff5

Please sign in to comment.