Skip to content

Commit

Permalink
Don't save lastCreated if existingLastCreated >= lastCreated (#64)
Browse files Browse the repository at this point in the history
* ignoring HttpConnectTimeoutException

* unwrapping ExecutionException

* ignoring java.net.ConnectException

* set spring.datasource.hikari.maximum-pool-size=1

* don't save lastCreated if existingLastCreated >= lastCreated
  • Loading branch information
yvasyliev authored May 31, 2024
1 parent e7bcf04 commit a5eedfd
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ public Optional<Integer> findLastCreated() {

@Transactional
public RedditTelegramForwarderProperty saveLastCreated(int lastCreated) {
return propertyRepository.saveAndFlush(new RedditTelegramForwarderProperty(
RedditTelegramForwarderPropertyName.LAST_CREATED,
String.valueOf(lastCreated))
);
var existingLastCreated = findLastCreated().orElse(0);
if (existingLastCreated < lastCreated) {
return propertyRepository.saveAndFlush(new RedditTelegramForwarderProperty(
RedditTelegramForwarderPropertyName.LAST_CREATED,
String.valueOf(lastCreated))
);
}
return null;
}
}

0 comments on commit a5eedfd

Please sign in to comment.