Refined BulkOperationRepository timeout handling logic: renamed timeout to cleanupTimeouts and expanded state conditions to include SCHEDULED.

This commit is contained in:
Jan 2025-11-07 18:39:19 +01:00
parent 1b1356e590
commit 982b637d47

View file

@ -119,7 +119,7 @@ public class BulkOperationRepository {
@Transactional
public List<BulkOperation> listByUserId(Integer userId) {
timeout(userId);
cleanupTimeouts(userId);
String sql = """
SELECT id, user_id, bulk_file_type, bulk_processing_type, state, created_at, validity_period_id
@ -132,10 +132,10 @@ public class BulkOperationRepository {
return jdbcTemplate.query(sql, new BulkOperationRowMapper(true), userId);
}
private void timeout(Integer userId) {
private void cleanupTimeouts(Integer userId) {
String sql = """
UPDATE bulk_operation SET state = 'EXCEPTION' WHERE user_id = ? AND state = 'PROCESSING' AND created_at < NOW() - INTERVAL 30 MINUTE
UPDATE bulk_operation SET state = 'EXCEPTION' WHERE user_id = ? AND (state = 'PROCESSING' OR state = 'SCHEDULED') AND created_at < NOW() - INTERVAL 30 MINUTE
""";
jdbcTemplate.update(sql, userId);