This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
173 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@namespace("no.nav.paw.arbeidssokerregisteret.intern.v1") | ||
protocol HendelseStartetV1 { | ||
import idl "metadata-v1.avdl"; | ||
record Startet { | ||
string identitetsnummer; | ||
Metadata metadata; | ||
} | ||
} |
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,8 @@ | ||
@namespace("no.nav.paw.arbeidssokerregisteret.intern.v1") | ||
protocol HendelseStoppetV1 { | ||
import idl "metadata-v1.avdl"; | ||
record Stoppet { | ||
string identitetsnummer; | ||
Metadata metadata; | ||
} | ||
} |
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,11 @@ | ||
@namespace("no.nav.paw.arbeidssokerregisteret.intern.v1") | ||
protocol Bruker { | ||
enum BrukerType { | ||
UKJENT_VERDI, UDEFINERT, VEILEDER, SYSTEM, SLUTTBRUKER | ||
} = UKJENT_VERDI; | ||
|
||
record Bruker { | ||
BrukerType type; | ||
string id; | ||
} | ||
} |
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,12 @@ | ||
@namespace("no.nav.paw.arbeidssokerregisteret.intern.v1") | ||
protocol Endring { | ||
import idl "bruker-v1.avdl"; | ||
|
||
record Metadata { | ||
@logicalType("timestamp-millis") | ||
long tidspunkt; | ||
Bruker utfoertAv; | ||
string kilde; | ||
string aarsak; | ||
} | ||
} |
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
66 changes: 66 additions & 0 deletions
66
...otlin/no/nav/fo/veilarbregistrering/arbeidssoker/perioder/ArbeidssokerperiodeScheduler.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,66 @@ | ||
package no.nav.fo.veilarbregistrering.arbeidssoker.perioder | ||
|
||
import no.nav.common.job.leader_election.LeaderElectionClient | ||
import no.nav.fo.veilarbregistrering.arbeidssoker.ArbeidssokerperiodeService | ||
import no.nav.fo.veilarbregistrering.log.logger | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.Bruker | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.BrukerType | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.Startet | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import java.time.ZoneOffset | ||
|
||
class ArbeidssokerperiodeScheduler( | ||
private val leaderElectionClient: LeaderElectionClient, | ||
private val arbeidssokerperiodeService: ArbeidssokerperiodeService, | ||
) { | ||
@Scheduled(cron = "* * * * *") | ||
fun start() { | ||
if (!leaderElectionClient.isLeader) { | ||
return | ||
} | ||
logger.info("Starter jobb for å overføre arbeidssøkerperioder") | ||
|
||
val arbeidssokerperioder = arbeidssokerperiodeService.hentNesteArbeidssokerperioder() | ||
|
||
if (arbeidssokerperioder.isEmpty()) { | ||
logger.info("Fant ingen arbeidssøkerperioder som skal overføres") | ||
return | ||
} | ||
|
||
val startHendelseTilOverforing = arbeidssokerperioder.map { | ||
Startet( | ||
it.foedselsnummer.foedselsnummer, | ||
no.nav.paw.arbeidssokerregisteret.intern.v1.Metadata( | ||
it.fra.toInstant(ZoneOffset.of("Europe/Oslo")), | ||
Bruker( | ||
BrukerType.SLUTTBRUKER, | ||
it.foedselsnummer.foedselsnummer, | ||
), | ||
"veilarbregistrering", | ||
"overføring", | ||
), | ||
) | ||
} | ||
|
||
val stoppHendelseTilOverforing = arbeidssokerperioder | ||
.filter { it.til != null } | ||
.map { | ||
no.nav.paw.arbeidssokerregisteret.intern.v1.Stoppet( | ||
it.foedselsnummer.foedselsnummer, | ||
no.nav.paw.arbeidssokerregisteret.intern.v1.Metadata( | ||
it.til!!.toInstant(ZoneOffset.of("Europe/Oslo")), | ||
Bruker( | ||
BrukerType.SLUTTBRUKER, | ||
it.foedselsnummer.foedselsnummer, | ||
), | ||
"veilarbregistrering", | ||
"overføring", | ||
), | ||
) | ||
} | ||
logger.info("Start hendelser til overføring ${startHendelseTilOverforing.size}") | ||
logger.info("Stopp hendelser til overføring ${stoppHendelseTilOverforing.size}") | ||
|
||
// arbeidssokerperiodeService.settArbeidssokerperioderSomOverfort(arbeidssokerperioder.map { it.id }) | ||
} | ||
} |
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
2 changes: 2 additions & 0 deletions
2
src/main/resources/db/migration/postgres/V15__arbeidssokerperiode_overforing.sql
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,2 @@ | ||
ALTER table arbeidssokerperiode | ||
ADD COLUMN overfort_kafka boolean NOT NULL DEFAULT false; |