Skip to content

Commit

Permalink
Fix bas sql
Browse files Browse the repository at this point in the history
  • Loading branch information
holymaloney committed Mar 7, 2024
1 parent b7e1b5b commit 44112d6
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ class HistoriskDeltakelseRepo(
tailrec fun getNextFreeDeltakerId(forrigeLedige: DeltakelseId, retries: Int = 0): DeltakelseId {
if (retries > 100) throw IllegalStateException("Mer enn hundre rekursive kall til getNextFreeDeltakerId. ForrigeLedigeDeltakerId: ${forrigeLedige}")
val sql = """
select ledig.ledig
from generate_series(:nesteMinDeltakelseId, :max) as ledig
where ledig.ledig not in (
select deltaker_id from deltaker_gjennomforing
where deltaker_id between :nesteMinDeltakelseId AND :max
) and not in (
select hist_tiltakdeltaker_id from deleted_singles_hist_format
where deltaker_id between :nesteMinDeltakelseId AND :max
) and not in (
select tiltakdeltaker_id from dobledeltakelser_jn
where deltaker_id between :nesteMinDeltakelseId AND :max
) limit 1
select ledig.ledig
from generate_series(:nesteMinDeltakelseId, :max) as ledig
where ledig.ledig not in (
select deltaker_id from deltaker_gjennomforing
where deltaker_id between :nesteMinDeltakelseId AND :max
) and ledig.ledig not in (
select hist_tiltakdeltaker_id from deleted_singles_hist_format
where hist_tiltakdeltaker_id between :nesteMinDeltakelseId AND :max
) and ledig.ledig not in (
select tiltakdeltaker_id from dobledeltakelser_jn
where tiltakdeltaker_id between :nesteMinDeltakelseId AND :max
) limit 1;
""".trimIndent()
val nesteMinDeltakelseId = forrigeLedige.value + 1
val maxDeltakelseId = nesteMinDeltakelseId + 5000
Expand Down

0 comments on commit 44112d6

Please sign in to comment.