Skip to content

Commit

Permalink
Stopper nå alle kjørende bestillinger, uten cutoff time.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc3092 committed Sep 6, 2024
1 parent 9d92043 commit b71188c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import no.nav.dolly.repository.BestillingRepository;
import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@RequiredArgsConstructor
Expand Down Expand Up @@ -32,10 +33,11 @@ public int getPhase() {
}

@Override
@Transactional
public void start() {
isRunning = true;
var result = repository.stopOrphanedRunning();
log.info("Stopped {} orphans", result);
var unfinished = repository.stopAllUnfinished();
log.info("Stoppet {} kjørende bestilling(er)", unfinished);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,12 @@ public interface BestillingRepository extends CrudRepository<Bestilling, Long> {
Optional<Bestilling> findByIdAndLock(@Param("id") Long id);

@Modifying
@Query(
nativeQuery = true,
value = """
update bestilling b
set ferdig = true, stoppet = true
where b.ferdig = false
and b.sist_oppdatert < now() - interval '2 minutes'
"""
)
int stopOrphanedRunning();
@Query("""
update Bestilling b
set b.ferdig = true,
b.stoppet = true
where b.ferdig = false
""")
int stopAllUnfinished();

}

0 comments on commit b71188c

Please sign in to comment.