Skip to content

Commit 0c913da

Browse files
Legge til logger for testing av oppdater av inntekt
1 parent 1ce4480 commit 0c913da

File tree

5 files changed

+63
-49
lines changed

5 files changed

+63
-49
lines changed

.github/workflows/deploy.yaml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
deploy-dev:
5050
name: Deploy to dev
5151
needs: [build]
52-
if: github.ref == 'refs/heads/main'
52+
if: github.ref == 'refs/heads/test-logs'
5353
runs-on: ubuntu-latest
5454
permissions:
5555
contents: "read"
@@ -64,21 +64,21 @@ jobs:
6464
VARS: nais/vars.yaml
6565
VAR: image=${{ needs.build.outputs.image }}
6666
PRINT_PAYLOAD: true
67-
deploy-prod:
68-
name: Deploy to Production
69-
needs: [build, deploy-dev]
70-
if: github.ref == 'refs/heads/main'
71-
runs-on: ubuntu-latest
72-
permissions:
73-
contents: "read"
74-
id-token: "write"
75-
environment: prod-gcp
76-
steps:
77-
- uses: actions/checkout@v4
78-
- uses: nais/deploy/actions/deploy@v2
79-
env:
80-
CLUSTER: prod-gcp
81-
RESOURCE: nais/prod/nais.yaml
82-
VARS: nais/vars.yaml
83-
VAR: image=${{ needs.build.outputs.image }}
84-
PRINT_PAYLOAD: true
67+
# deploy-prod:
68+
# name: Deploy to Production
69+
# needs: [build, deploy-dev]
70+
# if: github.ref == 'refs/heads/main'
71+
# runs-on: ubuntu-latest
72+
# permissions:
73+
# contents: "read"
74+
# id-token: "write"
75+
# environment: prod-gcp
76+
# steps:
77+
# - uses: actions/checkout@v4
78+
# - uses: nais/deploy/actions/deploy@v2
79+
# env:
80+
# CLUSTER: prod-gcp
81+
# RESOURCE: nais/prod/nais.yaml
82+
# VARS: nais/vars.yaml
83+
# VAR: image=${{ needs.build.outputs.image }}
84+
# PRINT_PAYLOAD: true

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/InntektApi.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ internal fun Application.inntektApi(
7676
install(StatusPages) {
7777
exception<Throwable> { call, cause ->
7878
LOGGER.error("Request failed!", cause)
79+
cause.printStackTrace()
7980
val error =
8081
Problem(
8182
type = URI("urn:dp:error:inntekt"),

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/db/PostgresInntektStore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ internal class PostgresInntektStore(
9595

9696
override fun getInntektPersonMapping(inntektId: String): InntektPersonMapping {
9797
@Language("sql")
98-
val statement = "SELECT * FROM inntekt_V1_person_mapping WHERE inntektId = :inntektId)".trimMargin()
98+
val statement = "SELECT * FROM inntekt_V1_person_mapping WHERE inntektId = :inntektId".trimMargin()
9999

100100
return using(sessionOf(dataSource)) { session ->
101101
session.run(

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/v1/UklassifisertInntektRoute.kt

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,28 +176,33 @@ fun Route.uklassifisertInntekt(
176176
.mapToStoredInntekt(
177177
inntektId = inntektId,
178178
).let {
179-
val inntektPersonMapping = inntektStore.getInntektPersonMapping(inntektId)
180-
inntektStore.storeInntekt(
181-
StoreInntektCommand(
182-
inntektparametre =
183-
Inntektparametre(
184-
aktørId = inntektPersonMapping.aktørId,
185-
fødselsnummer = it.inntekt.ident.identifikator,
186-
regelkontekst =
187-
RegelKontekst(
188-
inntektPersonMapping.kontekstId,
189-
inntektPersonMapping.kontekstType,
190-
),
191-
beregningsdato = inntektPersonMapping.beregningsdato,
192-
),
193-
inntekt = it.inntekt,
194-
manueltRedigert =
195-
ManueltRedigert.from(
196-
true,
197-
call.getSubject(),
198-
),
199-
),
200-
)
179+
try {
180+
val inntektPersonMapping = inntektStore.getInntektPersonMapping(inntektId)
181+
inntektStore.storeInntekt(
182+
StoreInntektCommand(
183+
inntektparametre =
184+
Inntektparametre(
185+
aktørId = inntektPersonMapping.aktørId,
186+
fødselsnummer = it.inntekt.ident.identifikator,
187+
regelkontekst =
188+
RegelKontekst(
189+
inntektPersonMapping.kontekstId,
190+
inntektPersonMapping.kontekstType,
191+
),
192+
beregningsdato = inntektPersonMapping.beregningsdato,
193+
),
194+
inntekt = it.inntekt,
195+
manueltRedigert =
196+
ManueltRedigert.from(
197+
true,
198+
call.getSubject(),
199+
),
200+
),
201+
)
202+
} catch (e: Throwable) {
203+
logger.error { e }
204+
throw e
205+
}
201206
}.let {
202207
call.respond(HttpStatusCode.OK, it.inntektId.id)
203208
}.also {

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/v1/models/InntekterDto.kt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package no.nav.dagpenger.inntekt.v1.models
22

3+
import mu.KotlinLogging
34
import no.nav.dagpenger.inntekt.db.InntektId
45
import no.nav.dagpenger.inntekt.db.StoredInntekt
56
import no.nav.dagpenger.inntekt.inntektskomponenten.v1.Aktoer
@@ -19,13 +20,20 @@ data class InntekterDto(
1920
val mottaker: Inntektsmottaker,
2021
)
2122

22-
fun InntekterDto.mapToStoredInntekt(inntektId: String): StoredInntekt =
23-
StoredInntekt(
24-
inntektId = InntektId(id = inntektId),
25-
inntekt = mapToInntektkomponentResponse(this),
26-
manueltRedigert = true,
27-
timestamp = now(),
28-
)
23+
fun InntekterDto.mapToStoredInntekt(inntektId: String): StoredInntekt {
24+
val logger = KotlinLogging.logger {}
25+
return try {
26+
StoredInntekt(
27+
inntektId = InntektId(id = inntektId),
28+
inntekt = mapToInntektkomponentResponse(this),
29+
manueltRedigert = true,
30+
timestamp = now(),
31+
)
32+
} catch (e: Throwable) {
33+
logger.error("Kunne ikke mappe InntekterDto til StoredInntekt", e)
34+
throw e
35+
}
36+
}
2937

3038
private fun mapToInntektkomponentResponse(inntekterDto: InntekterDto): InntektkomponentResponse {
3139
val inntektPerÅrOgMåned = mutableMapOf<YearMonth, Pair<MutableList<Inntekt>?, MutableList<Avvik>?>>()

0 commit comments

Comments
 (0)