Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
r Gjør kall mot PDL med systemkontekst og kjør kun batchjobb i leader…
Browse files Browse the repository at this point in the history
…-pod
  • Loading branch information
marenger committed Feb 27, 2023
1 parent 23bd8cd commit 1310517
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package no.nav.fo.veilarbregistrering.arbeidssoker.perioder

import no.nav.common.job.leader_election.LeaderElectionClient
import no.nav.fo.veilarbregistrering.aktorIdCache.AktorIdCacheRepository
import no.nav.fo.veilarbregistrering.bruker.Bruker
import no.nav.fo.veilarbregistrering.bruker.PdlOppslagGateway
import no.nav.fo.veilarbregistrering.log.logger
import no.nav.fo.veilarbregistrering.log.secureLogger
import org.springframework.scheduling.annotation.Scheduled

class PopulerHistoriskePerioderScheduler(
private val populerArbeidssokerperioderService: PopulerArbeidssokerperioderService,
private val pdlOppslagGateway: PdlOppslagGateway,
private val aktorIdCacheRepository: AktorIdCacheRepository
private val aktorIdCacheRepository: AktorIdCacheRepository,
private val leaderElectionClient: LeaderElectionClient
) {

@Scheduled(initialDelay = 180000, fixedDelay = Long.MAX_VALUE)
fun populerHistoriskePerioder() {
if (!leaderElectionClient.isLeader) {
return
}

logger.info("Starter jobb for å populere arbeidssøkerperioder")
val tilfeldigeFnr = aktorIdCacheRepository.hentTilfeldigFnr(5)

tilfeldigeFnr.forEach {
val identer = pdlOppslagGateway.hentIdenter(it.aktorId)
val identer = pdlOppslagGateway.hentIdenter(fnr = it.foedselsnummer, erSystemKontekst = true)

val arbeidssoker = populerArbeidssokerperioderService.hentArbeidssøker(
Bruker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package no.nav.fo.veilarbregistrering.config
import no.nav.common.auth.context.AuthContextHolder
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.health.selftest.SelfTestChecks
import no.nav.common.job.leader_election.LeaderElectionClient
import no.nav.fo.veilarbregistrering.aktorIdCache.AktorIdCacheRepository
import no.nav.fo.veilarbregistrering.aktorIdCache.AktorIdCacheService
import no.nav.fo.veilarbregistrering.arbeidsforhold.ArbeidsforholdGateway
Expand Down Expand Up @@ -327,12 +328,14 @@ class ServiceBeansConfig {
fun populerArbeiddsokerPerioderScheduler(
populerArbeidssokerperioderService: PopulerArbeidssokerperioderService,
pdlOppslagGateway: PdlOppslagGateway,
aktorIdCacheRepository: AktorIdCacheRepository
aktorIdCacheRepository: AktorIdCacheRepository,
leaderElectionClient: LeaderElectionClient
): PopulerHistoriskePerioderScheduler {
return PopulerHistoriskePerioderScheduler(
populerArbeidssokerperioderService,
pdlOppslagGateway,
aktorIdCacheRepository
aktorIdCacheRepository,
leaderElectionClient
)
}

Expand Down

0 comments on commit 1310517

Please sign in to comment.