From 488719539561cde4b5ceb63990cb85c5e9965dd8 Mon Sep 17 00:00:00 2001 From: Mykola Rudyk Date: Mon, 12 Feb 2024 10:37:19 +0200 Subject: [PATCH] fix: remove PR if max attempt reached Signed-off-by: Mykola Rudyk --- .../java/com/lpvs/service/LPVSQueueService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/lpvs/service/LPVSQueueService.java b/src/main/java/com/lpvs/service/LPVSQueueService.java index 977cf8a2..45d8f8a1 100644 --- a/src/main/java/com/lpvs/service/LPVSQueueService.java +++ b/src/main/java/com/lpvs/service/LPVSQueueService.java @@ -271,7 +271,18 @@ public void processWebHook(LPVSQueue webhookConfig) { pullRequest = lpvsPullRequestRepository.saveAndFlush(pullRequest); log.error("Can't authorize commentResults() " + e); e.printStackTrace(); - delete(webhookConfig); + int currentAttempts = webhookConfig.getAttempts(); + if (currentAttempts < maxAttempts) { + webhookConfig.setAttempts(currentAttempts + 1); + queueRepository.save(webhookConfig); + } else { + log.warn( + "Maximum amount of processing webhook reached for pull request: " + + pullRequest.getId() + + " " + + pullRequest.toString()); + delete(webhookConfig); + } } } }