class TppStopListScheduleTask {

    @Scheduled(cron = "${xs2a.cms.stoplist.cron.expression}")
    @Transactional
    public void unblockTppIfBlockingExpired() {
        log.info("Tpp Stop List schedule task is run!");

        List<TppStopListEntity> blockedWithExpirationTpps = tppStopListRepository.findAllByStatusAndBlockingExpirationTimestampLessThanEqual(TppStatus.BLOCKED, OffsetDateTime.now());
        List<TppStopListEntity> unblockedTpps = unblockTpps(blockedWithExpirationTpps);

        if (!unblockedTpps.isEmpty()) {
            tppStopListRepository.saveAll(unblockedTpps);
        }
    }

}