Changed cron from daily to hourly (#132)

Co-authored-by: Inal Arsanukaev <inalarsanukaev@MacBook-Pro-Inal.local>
This commit is contained in:
Inal Arsanukaev 2020-11-12 17:15:26 +03:00 committed by GitHub
parent dc15f448d4
commit 7048df31bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 6 deletions

2
.gitignore vendored
View File

@ -71,3 +71,5 @@ fabric.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
env.list env.list
.DS_Store

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>hooker</artifactId> <artifactId>hooker</artifactId>
<version>2.0.57-SNAPSHOT</version> <version>2.0.58-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>hooker</name> <name>hooker</name>

View File

@ -14,7 +14,7 @@ public class CleanTablesDao {
private final NamedParameterJdbcTemplate jdbcTemplate; private final NamedParameterJdbcTemplate jdbcTemplate;
public int cleanInvocingDaily(int daysAgo) { public int cleanInvocing(int daysAgo) {
final String sql = final String sql =
" with excluded_ids as (" + " with excluded_ids as (" +
" select queue_id from hook.scheduled_task st " + " select queue_id from hook.scheduled_task st " +

View File

@ -20,7 +20,7 @@ public class CleanTablesService {
@Scheduled(cron = "${clean.scheduler.cron}", zone = "${clean.scheduler.timezone}") @Scheduled(cron = "${clean.scheduler.cron}", zone = "${clean.scheduler.timezone}")
public void loop() { public void loop() {
log.info("Start daily cleaning of invoicing queue tables, days ago = {}", daysAgo); log.info("Start daily cleaning of invoicing queue tables, days ago = {}", daysAgo);
int affectedRows = cleanTablesDao.cleanInvocingDaily(daysAgo); int affectedRows = cleanTablesDao.cleanInvocing(daysAgo);
log.info("End daily cleaning of invoicing queue tables, rows deleted = {}", affectedRows); log.info("End daily cleaning of invoicing queue tables, rows deleted = {}", affectedRows);
} }

View File

@ -84,7 +84,7 @@ message:
clean: clean:
scheduler: scheduler:
cron: "0 0 10 * * *" cron: "0 0 * * * *"
timezone: Europe/Moscow timezone: Europe/Moscow
daysAgo: 30 daysAgo: 30

View File

@ -19,7 +19,7 @@ public class CleanTablesDaoTest extends AbstractIntegrationTest {
private NamedParameterJdbcTemplate jdbcTemplate; private NamedParameterJdbcTemplate jdbcTemplate;
@Test @Test
public void cleanInvocingDaily() { public void cleanInvocingTest() {
String sql = "with queue as ( " + String sql = "with queue as ( " +
" insert into hook.invoicing_queue(hook_id, invoice_id, wtime) " + " insert into hook.invoicing_queue(hook_id, invoice_id, wtime) " +
@ -41,7 +41,7 @@ public class CleanTablesDaoTest extends AbstractIntegrationTest {
}); });
int count = cleanTablesDao.cleanInvocingDaily(10); int count = cleanTablesDao.cleanInvocing(10);
assertEquals(count, countOldRecords); assertEquals(count, countOldRecords);
long newRecordsCount = jdbcTemplate.queryForObject("select count(*) from hook.invoicing_queue", new MapSqlParameterSource(), Long.class); long newRecordsCount = jdbcTemplate.queryForObject("select count(*) from hook.invoicing_queue", new MapSqlParameterSource(), Long.class);