From 524e0ca4dd70649777a9dbcd025077a6c2e64ca1 Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Thu, 21 Sep 2023 13:51:24 -0400
Subject: [PATCH] Iss #145 - Add configurable frequency for GH revalidation,
 fix count

---
 .../git/eca/tasks/GithubRevalidationQueue.java         | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubRevalidationQueue.java b/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubRevalidationQueue.java
index dd52e71e..02ea0c4e 100644
--- a/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubRevalidationQueue.java
+++ b/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubRevalidationQueue.java
@@ -75,7 +75,7 @@ public class GithubRevalidationQueue {
      * Every 5s, this method will attempt to load a Github webhook validation request that has the needs revalidation flag
      * set to true. This will retrieve the oldest request in queue and will attempt to revalidate it.
      */
-    @Scheduled(every = "5s")
+    @Scheduled(every = "${eclipse.git-eca.tasks.gh-revalidation.frequency:60s}")
     @ActivateRequestContext
     public void revalidate() {
         // if not enabled, don't process any potentially OOD records
@@ -114,6 +114,10 @@ public class GithubRevalidationQueue {
                 .debug("Attempting revalidation of request w/ ID {}, in repo {}#{}", requestToRevalidate.getId(),
                         requestToRevalidate.getRepositoryFullName(), requestToRevalidate.getPullRequestNumber());
 
+        // update the number of times this status has revalidated (tracking)
+        requestToRevalidate
+                .setManualRevalidationCount(requestToRevalidate.getManualRevalidationCount() == null ? 1
+                        : requestToRevalidate.getManualRevalidationCount() + 1);
         // wrap in try-catch to avoid errors from stopping the record updates
         try {
             // split the full repo name into the org and repo name
@@ -130,10 +134,6 @@ public class GithubRevalidationQueue {
             requestToRevalidate.setNeedsRevalidation(false);
             LOGGER.debug("Sucessfully revalidated request w/ ID {}", requestToRevalidate.getId());
         } catch (RuntimeException e) {
-            // update the number of times this status has revalidated (tracking)
-            requestToRevalidate
-                    .setManualRevalidationCount(requestToRevalidate.getManualRevalidationCount() == null ? 1
-                            : requestToRevalidate.getManualRevalidationCount() + 1);
             // log the message so we can see what happened
             LOGGER.error("Error while revalidating request w/ ID {}", requestToRevalidate.getId(), e);
         } finally {
-- 
GitLab