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

speed up spørring for å hente varsler som skal sendes #903

Merged
merged 1 commit into from
Dec 23, 2024
Merged
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 @@ -58,18 +58,31 @@ public List<SkalSendes> hentVarselSomSkalSendes(int maxAntall) {

return jdbcTemplate
.query("""
select ID, BRUKERNOTIFIKASJON_ID, MELDING, OPPFOLGINGSPERIODE, FOEDSELSNUMMER, TYPE, SMSTEKST, EPOSTTITTEL, EPOSTBODY, URL
from BRUKERNOTIFIKASJON B
where STATUS = 'PENDING'
and not exists(
Select * from AKTIVITET A
inner join AKTIVITET_BRUKERNOTIFIKASJON AB on A.AKTIVITET_ID = AB.AKTIVITET_ID
where AB.BRUKERNOTIFIKASJON_ID = B.ID
and A.GJELDENDE = 1
and TYPE in ('STILLING_FRA_NAV', 'FORHAANDSORENTERING')
and (A.HISTORISK_DATO is not null or A.LIVSLOPSTATUS_KODE in('FULLFORT', 'AVBRUTT'))
)
limit :limit
SELECT
B.ID,
B.BRUKERNOTIFIKASJON_ID,
B.MELDING,
B.OPPFOLGINGSPERIODE,
B.FOEDSELSNUMMER,
B.TYPE,
B.SMSTEKST,
B.EPOSTTITTEL,
B.EPOSTBODY,
B.URL
FROM
BRUKERNOTIFIKASJON B
LEFT JOIN
AKTIVITET_BRUKERNOTIFIKASJON AB ON B.ID = AB.BRUKERNOTIFIKASJON_ID
LEFT JOIN
AKTIVITET A ON A.AKTIVITET_ID = AB.AKTIVITET_ID
AND A.GJELDENDE = 1
AND B.TYPE IN ('STILLING_FRA_NAV', 'FORHAANDSORENTERING')
AND (A.HISTORISK_DATO IS NOT NULL
OR A.LIVSLOPSTATUS_KODE IN('FULLFORT', 'AVBRUTT'))
WHERE
B.STATUS = 'PENDING' AND
A.AKTIVITET_ID IS NULL
LIMIT :limit;
""",
parameterSource, rowMapper);
}
Expand Down
Loading