etreshenkov 2023-11-03 13:15:49 +03:00
parent 9b26fb2290
commit 60e7c6ac39

View file

@ -16,7 +16,6 @@ import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import static ru.spcex.clearing.imdg.base.ObjectBaseMapStore.MAX_IN_CLAUSE_SIZE; import static ru.spcex.clearing.imdg.base.ObjectBaseMapStore.MAX_IN_CLAUSE_SIZE;
@ -77,14 +76,8 @@ public abstract class AbstractSliceMapLoader<T extends WithId> implements Autoco
@Override @Override
public Iterable<Long> loadAllKeys() { public Iterable<Long> loadAllKeys() {
log.debug("loading all keys from {}...", getTableName()); log.debug("loading all keys from {}...", getTableName());
LocalDate yesterdayInstant = LocalDate.now().minus(0, ChronoUnit.DAYS); List<Long> ids = jdbcTemplate.query("select id from " + getTableName(),
// Instant yesterdayInstant = Instant.now().minus(0, ChronoUnit.DAYS); (resultSet, i) -> resultSet.getLong("id"));
LocalDate fewDaysAgo = yesterdayInstant.minus(2, ChronoUnit.DAYS);
String fieldOfDay = fieldOfDay();
List<Long> ids = jdbcTemplate.query("select id from " + getTableName() + " where " + fieldOfDay + " <= ? " +
"and " + fieldOfDay + " >= ? ",
(resultSet, i) -> resultSet.getLong("id"),
yesterdayInstant, fewDaysAgo);
log.debug("loading all keys from {} done; size={}", getTableName(), ids.size()); log.debug("loading all keys from {} done; size={}", getTableName(), ids.size());
return ids; return ids;
} }