Skip to content

Commit ba40670

Browse files
committed
Logg likt i alle uklassifisert routes
1 parent fa75c32 commit ba40670

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

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

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fun Route.uklassifisertInntekt(
6262
route("/uklassifisert/{aktørId}/{kontekstType}/{kontekstId}/{beregningsDato}") {
6363
get {
6464
withContext(Dispatchers.IO) {
65-
withInntektRequest {
65+
withInntektRequest("GET /uklassifisert/") {
6666
inntektStore.getInntektId(
6767
Inntektparametre(
6868
aktørId = this.aktørId,
@@ -83,7 +83,7 @@ fun Route.uklassifisertInntekt(
8383
}
8484
post {
8585
withContext(Dispatchers.IO) {
86-
withInntektRequest {
86+
withInntektRequest("POST /uklassifisert/") {
8787
val guiInntekt = call.receive<GUIInntekt>()
8888
mapToStoredInntekt(guiInntekt).let {
8989
inntektStore.storeInntekt(
@@ -121,37 +121,29 @@ fun Route.uklassifisertInntekt(
121121
get {
122122
val callId = call.callId
123123
withContext(Dispatchers.IO) {
124-
withInntektRequest {
125-
withLoggingContext(
126-
"route" to "/uklassifisert/uncached",
127-
"aktørId" to aktørId,
128-
"kontekstType" to kontekstType,
129-
"kontekstId" to kontekstId,
130-
"beregningsDato" to beregningsDato.toString()
131-
) {
132-
val opptjeningsperiode = Opptjeningsperiode(this.beregningsDato)
133-
toInntektskomponentRequest(this, opptjeningsperiode).let {
134-
logger.info { "Henter nye inntekter fra inntektskomponenten" }
135-
inntektskomponentClient.getInntekt(it, callId = callId)
136-
}.let {
137-
logger.info { "Fikk nye inntekter fra inntektskomponenten" }
138-
val person = personOppslag.hentPerson(this.aktørId)
139-
val inntektsmottaker =
140-
Inntektsmottaker(person?.fødselsnummer, person?.sammensattNavn())
141-
mapToGUIInntekt(it, opptjeningsperiode, inntektsmottaker)
142-
}.let {
143-
call.respond(HttpStatusCode.OK, it)
144-
}.also {
145-
inntektOppfriskingCounter.inc()
146-
}
124+
withInntektRequest("GET /uklassifisert/uncached/") {
125+
val opptjeningsperiode = Opptjeningsperiode(this.beregningsDato)
126+
toInntektskomponentRequest(this, opptjeningsperiode).let {
127+
logger.info { "Henter nye inntekter fra inntektskomponenten" }
128+
inntektskomponentClient.getInntekt(it, callId = callId)
129+
}.let {
130+
logger.info { "Fikk nye inntekter fra inntektskomponenten" }
131+
val person = personOppslag.hentPerson(this.aktørId)
132+
val inntektsmottaker =
133+
Inntektsmottaker(person?.fødselsnummer, person?.sammensattNavn())
134+
mapToGUIInntekt(it, opptjeningsperiode, inntektsmottaker)
135+
}.let {
136+
call.respond(HttpStatusCode.OK, it)
137+
}.also {
138+
inntektOppfriskingCounter.inc()
147139
}
148140
}
149141
}
150142
}
151143

152144
post {
153145
withContext(Dispatchers.IO) {
154-
withInntektRequest {
146+
withInntektRequest("POST /uklassifisert/uncached/") {
155147
val guiInntekt = call.receive<GUIInntekt>()
156148
mapToDetachedInntekt(guiInntekt).let {
157149
inntektStore.storeInntekt(
@@ -209,7 +201,10 @@ private fun PipelineContext<Unit, ApplicationCall>.getSubject(): String {
209201
}
210202
}
211203

212-
private inline fun PipelineContext<Unit, ApplicationCall>.withInntektRequest(block: InntektRequest.() -> Unit) {
204+
private inline fun PipelineContext<Unit, ApplicationCall>.withInntektRequest(
205+
route: String,
206+
block: InntektRequest.() -> Unit
207+
) {
213208
val inntektRequest = runCatching {
214209
InntektRequest(
215210
aktørId = call.parameters["aktørId"]!!,
@@ -220,6 +215,7 @@ private inline fun PipelineContext<Unit, ApplicationCall>.withInntektRequest(blo
220215
}.getOrElse { t -> throw IllegalArgumentException("Failed to parse parameters", t) }
221216

222217
withLoggingContext(
218+
"route" to route,
223219
"kontekstId" to inntektRequest.kontekstId,
224220
"kontekstType" to inntektRequest.kontekstType
225221
) {

0 commit comments

Comments
 (0)