Skip to content

Commit

Permalink
Merge pull request #14 from rohit-zip/main
Browse files Browse the repository at this point in the history
feature/blog-scheduler
  • Loading branch information
rohit-zip authored Aug 29, 2024
2 parents f08ec1f + 6f9abd1 commit 85bd5ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ protected SchedulerDataDao(SchedulerDataRepository repository) {
}

public List<SchedulerData> getOverduePendingSchedulingData() {
return repository.findAllByIsSchedulingDoneTrueAndScheduleDateLessThanEqual(new Date());

return repository.findAllByScheduleDateLessThanEqual(new Date());
}

public void deleteByEntity(SchedulerData schedulerData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

public interface SchedulerDataRepository extends JpaRepository<SchedulerData, String> {

List<SchedulerData> findAllByIsSchedulingDoneTrueAndScheduleDateLessThanEqual(Date currentDate);
List<SchedulerData> findAllByScheduleDateLessThanEqual(Date currentDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.bloggios.blog.modal.SchedulerData;
import com.bloggios.blog.scheduler.TimeScheduler;
import com.bloggios.blog.scheduler.implementation.BlogSchedulerImplementation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
Expand All @@ -18,6 +20,7 @@
*/

@Component
@Slf4j
public class TwoMinutesScheduler implements TimeScheduler {

private final SchedulerDataDao schedulerDataDao;
Expand All @@ -33,7 +36,9 @@ public TwoMinutesScheduler(

@Override
public void initOperation() {
log.error("Scheduler Date : {}", new Date());
List<SchedulerData> overduePendingSchedulingData = schedulerDataDao.getOverduePendingSchedulingData();
log.error("Schedulers List: {}", overduePendingSchedulingData.size());
if (overduePendingSchedulingData.isEmpty()) return;
overduePendingSchedulingData
.forEach(schedulerData -> {
Expand Down

0 comments on commit 85bd5ae

Please sign in to comment.