-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
La til metrics for freg status og oppholdstillatelse
- Loading branch information
Showing
8 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...-perioder/src/main/kotlin/no/nav/paw/arbeidssokerregisteret/services/PersonInfoService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...pp-perioder/src/main/kotlin/no/nav/paw/arbeidssokerregisteret/services/PersonInfoStats.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package no.nav.paw.arbeidssokerregisteret.services | ||
|
||
import io.micrometer.core.instrument.Tag | ||
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry | ||
import no.nav.paw.arbeidssokerregisteret.application.opplysninger.DomeneOpplysning | ||
import no.nav.paw.arbeidssokerregisteret.application.opplysninger.Opplysning | ||
import no.nav.paw.pdl.graphql.generated.hentperson.Person | ||
import java.time.LocalDate | ||
import java.time.temporal.ChronoUnit | ||
|
||
fun PrometheusMeterRegistry.personInfoStats(person: Person, opplysninger: Collection<Opplysning>) { | ||
val tags = listOf( | ||
Tag.of("bosatt", opplysninger.contains(DomeneOpplysning.BosattEtterFregLoven).toString()), | ||
Tag.of( | ||
"oppholdstillatelse", | ||
opplysninger.find { it.id.contains("Oppholdstillatelse", ignoreCase = true) }?.id ?: "null" | ||
), | ||
Tag.of( | ||
"dager_siden_oppholdstillatelse_start", | ||
person.opphold.firstOrNull()?.oppholdFra?.let(LocalDate::parse)?.let(::daysBetweenNow)?.let(::asBucket) ?: "null" | ||
), | ||
Tag.of( | ||
"dager_til_oppholdstillatelse_stopp", | ||
person.opphold.firstOrNull()?.oppholdTil?.let(LocalDate::parse)?.let(::daysBetweenNow)?.let(::asBucket) ?: "null" | ||
), | ||
Tag.of( | ||
"avtale_land", (opplysninger.contains(DomeneOpplysning.ErEuEoesStatsborger) || opplysninger.contains(DomeneOpplysning.ErGbrStatsborger)).toString() | ||
) | ||
) | ||
counter("paw_arbeidssoeker_inngang_opplysninger", tags) | ||
} | ||
|
||
fun daysBetweenNow(then: LocalDate): Long { | ||
val now = LocalDate.now() | ||
return ChronoUnit.DAYS.between(now, then) | ||
} | ||
|
||
fun asBucket(number: Long): String = | ||
when { | ||
number < 14 -> "[0, 14>" | ||
number < 28 -> "[14-28>" | ||
number < 56 -> "[28-56>" | ||
number < 112 -> "[56-112>" | ||
number < 224 -> "[112-224>" | ||
else -> "[224-" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters