Skip to content

Commit 8f75dd5

Browse files
committed
kan nå hente med og uten dato på meldekortdetalj
1 parent 733925d commit 8f75dd5

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

app/main/api/postgres/MeldekortDetaljerRepository.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,14 @@ class MeldekortDetaljerRepository(private val connection: DBConnection) {
123123
}
124124
return connection.queryList(
125125
"""SELECT * FROM MELDEKORT WHERE PERSON_IDENT = ANY(?)
126-
AND ( ? IS NULL OR MOTTATT_TIDSPUNKT >= ?::date)
127-
AND ( ? IS NULL OR MOTTATT_TIDSPUNKT <= ?::date)
126+
AND MOTTATT_TIDSPUNKT >= COALESCE(CAST(? AS DATE), MOTTATT_TIDSPUNKT)
127+
AND MOTTATT_TIDSPUNKT <= COALESCE(CAST(? AS DATE), MOTTATT_TIDSPUNKT);
128128
""".trimIndent()
129129
) {
130130
setParams {
131131
setArray(1, personIdentifikatorer)
132132
setLocalDate(2, fom)
133-
setLocalDate(3, fom)
134-
setLocalDate(4, tom)
135-
setLocalDate(5, tom)
133+
setLocalDate(3, tom)
136134
}
137135
setRowMapper { row ->
138136
rowToMeldekortDTO(row)

app/test/api/meldekort/MeldekortDetaljerRepositoryTest.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import no.nav.aap.behandlingsflyt.kontrakt.sak.Saksnummer
3131
import org.junit.jupiter.api.AfterAll
3232
import org.junit.jupiter.api.Assertions.assertEquals
3333
import org.junit.jupiter.api.Test
34+
import java.time.LocalDate
3435
import java.time.LocalDateTime
3536

3637
val testObject = DetaljertMeldekortDTO(
@@ -88,7 +89,11 @@ class MeldekortDetaljerRepositoryTest : PostgresTestBase(dataSource) {
8889
val meldekortResponse = jsonHttpClient.post("/kelvin/meldekort-detaljer"){
8990
bearerAuth(azure.generate(isApp = true))
9091
contentType(ContentType.Application.Json)
91-
setBody(MeldekortDetaljerRequest("12345678901"))
92+
setBody(MeldekortDetaljerRequest(
93+
"12345678901",
94+
fraOgMedDato = LocalDate.now().minusYears(3),
95+
tilOgMedDato = LocalDate.now().plusDays(1)
96+
))
9297
}
9398

9499
assert(meldekortResponse.status == HttpStatusCode.OK)

0 commit comments

Comments
 (0)