Fixed purge external events job

This commit is contained in:
Arnold Galovics
2022-12-29 12:38:16 +01:00
committed by Arnold Gálovics
parent 7a9e696ac8
commit 77ee43acb8
4 changed files with 10 additions and 9 deletions
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.commands.domain;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
@@ -30,6 +30,6 @@ public interface CommandSourceRepository extends JpaRepository<CommandSource, Lo
@Modifying(flushAutomatically = true)
@Query("delete from CommandSource c where c.status = :status and c.madeOnDate is not null and c.madeOnDate <= :dateForPurgeCriteria")
void deleteOlderEventsWithStatus(CommandProcessingResultType status, LocalDate dateForPurgeCriteria);
void deleteOlderEventsWithStatus(Integer status, OffsetDateTime dateForPurgeCriteria);
}
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.commands.jobs;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.commands.domain.CommandProcessingResultType;
@@ -43,8 +43,8 @@ public class PurgeProcessedCommandsTasklet implements Tasklet {
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) {
try {
Long numberOfDaysForPurgeCriteria = configurationDomainService.retrieveProcessedCommandsPurgeDaysCriteria();
LocalDate dateForPurgeCriteria = DateUtils.getBusinessLocalDate().minusDays(numberOfDaysForPurgeCriteria);
repository.deleteOlderEventsWithStatus(CommandProcessingResultType.PROCESSED, dateForPurgeCriteria);
OffsetDateTime dateForPurgeCriteria = DateUtils.getOffsetDateTimeOfTenant().minusDays(numberOfDaysForPurgeCriteria);
repository.deleteOlderEventsWithStatus(CommandProcessingResultType.PROCESSED.getValue(), dateForPurgeCriteria);
} catch (Exception e) {
log.error("Error occurred while purging processed commands: ", e);
}