-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cronjob for outdated dialogmotekandidater (#138)
* Cronjob for outdated dialogmotekandidater * Remove redundant group by. Increase limit and job interval.
- Loading branch information
1 parent
3af8057
commit 5983fae
Showing
10 changed files
with
370 additions
and
5 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
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/no/nav/syfo/cronjob/dialogmotekandidat/DialogmotekandidatOutdatedCronjob.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,43 @@ | ||
package no.nav.syfo.cronjob.dialogmotekandidat | ||
|
||
import no.nav.syfo.cronjob.Cronjob | ||
import no.nav.syfo.cronjob.CronjobResult | ||
import no.nav.syfo.dialogmotekandidat.DialogmotekandidatService | ||
import no.nav.syfo.dialogmotekandidat.domain.DialogmotekandidatEndring | ||
import org.slf4j.LoggerFactory | ||
import java.time.LocalDate | ||
|
||
class DialogmotekandidatOutdatedCronjob( | ||
private val outdatedDialogmotekandidatCutoff: LocalDate, | ||
private val dialogmotekandidatService: DialogmotekandidatService, | ||
) : Cronjob { | ||
override val initialDelayMinutes: Long = 4 | ||
override val intervalDelayMinutes: Long = 10 | ||
|
||
override suspend fun run() { | ||
runJob() | ||
} | ||
|
||
fun runJob(): CronjobResult { | ||
val result = CronjobResult() | ||
|
||
val cutoff = outdatedDialogmotekandidatCutoff.atStartOfDay() | ||
val outdatedDialogmotekandidater = dialogmotekandidatService.getOutdatedDialogmotekandidater(cutoff) | ||
outdatedDialogmotekandidater.forEach { | ||
try { | ||
val dialogmotekandidatLukket = DialogmotekandidatEndring.lukket(it.personIdentNumber) | ||
dialogmotekandidatService.createDialogmotekandidatEndring(dialogmotekandidatLukket) | ||
result.updated++ | ||
} catch (e: Exception) { | ||
result.failed++ | ||
log.error("Got exception when creating dialogmotekandidat-endring LUKKET", e) | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(DialogmotekandidatOutdatedCronjob::class.java) | ||
} | ||
} |
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
Oops, something went wrong.