You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by GitBox <gi...@apache.org> on 2018/10/31 17:01:32 UTC

[GitHub] asfgit closed pull request #56: IGNITE-10091 Replace PR source for autocompleting branch fields

asfgit closed pull request #56: IGNITE-10091 Replace PR source for autocompleting branch fields
URL: https://github.com/apache/ignite-teamcity-bot/pull/56
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
index 3b998ee3..6a373668 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
@@ -52,6 +52,7 @@
 
     /** Ignite provider. */
     @Inject Provider<Ignite> igniteProvider;
+
     /** Scheduler. */
     @Inject IScheduler scheduler;
 
@@ -93,7 +94,7 @@ public void init(String srvId, IGitHubConnection conn) {
     }
 
     private void actualizePrs() {
-        runAtualizePrs(srvId, false);
+        runActualizePrs(srvId, false);
 
         // schedule full resync later
         scheduler.invokeLater(this::sheduleResync, 20, TimeUnit.SECONDS);
@@ -111,7 +112,7 @@ private void sheduleResync() {
      *
      */
     private void fullReindex() {
-        runAtualizePrs(srvId, true);
+        runActualizePrs(srvId, true);
     }
 
     /**
@@ -120,7 +121,7 @@ private void fullReindex() {
      */
     @MonitoredTask(name = "Actualize PRs(srv, full resync)", nameExtArgsIndexes = {0, 1})
     @AutoProfiling
-    protected String runAtualizePrs(String srvId, boolean fullReindex) {
+    protected String runActualizePrs(String srvId, boolean fullReindex) {
         AtomicReference<String> outLinkNext = new AtomicReference<>();
 
         List<PullRequest> ghData = conn.getPullRequests(null, outLinkNext);
diff --git a/ignite-tc-helper-web/src/main/webapp/index0.html b/ignite-tc-helper-web/src/main/webapp/index0.html
index 01106132..33ebb0fa 100644
--- a/ignite-tc-helper-web/src/main/webapp/index0.html
+++ b/ignite-tc-helper-web/src/main/webapp/index0.html
@@ -51,9 +51,8 @@
     $.ajax({
         url: "rest/branches/getServerIds",
         success: function(result) {
-            $("#loadStatus").html("");
-            setupAutocompleteList(result);
             showBuildsOnServers(result);
+            setAutocompleteFilter();
         },
         error: showErrInLoadStatus
     });
@@ -102,17 +101,28 @@
 
 function showBuildsOnServers(result) {
     var res = "";
+
     for (var i = 0; i < result.length; i++) {
-        var serverId = result[i];
+        let srvId = result[i];
         //res+="<a href='pr.html?serverId=private&branchForTc=ignite-gg-12790-1&suiteId=id8xIgniteGridGainTests_RunAll="+id+"'>Check PR</a><br>";
 
         res+="<form action='build.html'>";
-        res+="Server: <input type='text' name='serverId' value=" + serverId +" readonly>" ;
+        res+="Server: <input type='text' name='serverId' value=" + srvId +" readonly>" ;
         res+="Check Logs: <input type='text' name='checkAllLogs' style='width: 20%;' value='true' readonly>" ;
         res+="Build Id: <input type='text' name='buildId' required> ";
         res+="<input type='submit' name='action' value='Check'>";
         res+="</form>";
+
+        $.ajax({
+            url: "rest/visa/contributions?serverId=" + srvId,
+            success:
+                function (result) {
+                    $("#loadStatus").html("");
+                    fillBranchAutocompleteList(result, srvId);
+                }
+        });
     }
+
     $("#buildsCheck").html(res);
 }
 </script>
diff --git a/ignite-tc-helper-web/src/main/webapp/js/common-1.6.js b/ignite-tc-helper-web/src/main/webapp/js/common-1.6.js
index 613e4114..22469d5d 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/common-1.6.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/common-1.6.js
@@ -272,93 +272,27 @@ var gitUrls = new Map();
 var branchesForTc = {};
 
 /**
- * Fill git URLs and send requests to them.
+ * Fill autocomplete lists for the fields branchForTc.
  *
- * @param srvIds - Set of server IDs.
+ * @param result List of ContributionToCheck.
+ * @param srvId Server id.
  */
-function setupAutocompleteList(srvIds) {
-    for (let srvId of srvIds)
-        gitUrls.set(srvId, "");
-
-    setAutocompleteFilter();
-
-    startFillAutocompleteListsProcess();
-}
-
-/**
- * Retrieves recent PR numbers and fills autocomplete lists for the fields branchForTc.
- */
-function startFillAutocompleteListsProcess() {
-    _receiveIntegrationUrls();
-}
-
-/**
- * Receive api links for the servers.
- *
- * @private
- */
-function _receiveIntegrationUrls() {
-    var url = "rest/build/integrationUrls?serverIds=";
-
-    for (let key of gitUrls.keys())
-        url += key + ",";
-
-    $.ajax({
-        url: url,
-        success: function (result) {
-            _fillGitUrls(result);
-            _sendRequestsToFillAutocompleteLists();
-        }
-    });
-}
-
-/**
- * Fill git api URLs.
- *
- * @param result Array of ServerIntegrationLinks.
- *
- * @private
- */
-function _fillGitUrls(result) {
-    for (let links of result)
-        gitUrls.set(links.srvId, links.gitApiUrl);
-}
-
-/**
- * Send requests to the git to get pull requests for the branch autocomplete lists.
- *
- * @private
- */
-function _sendRequestsToFillAutocompleteLists() {
-    for (var entry of gitUrls.entries()) {
-        if (entry[1])
-            scriptRequest(entry[1] + "pulls?sort=updated&direction=desc", _fillBranchAutocompleteList);
-    }
-}
-
-/**
- * Takes all "branchForTc<server>" and add autocomplete list to them.
- *
- * @param result Response from git.
- */
-function _fillBranchAutocompleteList(result) {
-    if (!result.data || !result.data[0])
+function fillBranchAutocompleteList(result, srvId) {
+    if (!isDefinedAndFilled(result))
         return;
 
-    for (var entry of gitUrls.entries()) {
-        if (!result.data[0].url.startsWith(entry[1]))
-            continue;
+    if (!isDefinedAndFilled(gitUrls.get(srvId)))
+        gitUrls.set(srvId, "");
 
-        branchesForTc[entry[0]] = [{label:"master", value:"refs/heads/master"}];
+    branchesForTc[srvId] = [{label:"master", value:"refs/heads/master"}];
 
-        for (let pr of result.data) {
-            branchesForTc[entry[0]].push({label: pr.number + " " + pr.title, value: "pull/" + pr.number + "/head"});
-            branchesForTc[entry[0]].push({label: "pull/" + pr.number + "/head " + pr.title,
-                value: "pull/" + pr.number + "/head"});
-        }
-
-        $(".branchForTc" + entry[0]).autocomplete({source: branchesForTc[entry[0]]});
+    for (let pr of result) {
+        branchesForTc[srvId].push({label: pr.prNumber + " " + pr.prTitle, value: "pull/" + pr.prNumber + "/head"});
+        branchesForTc[srvId].push({label: "pull/" + pr.prNumber + "/head " + pr.prTitle,
+            value: "pull/" + pr.prNumber + "/head"});
     }
+
+    $(".branchForTc" + srvId).autocomplete({source: branchesForTc[srvId]});
 }
 
 /**
diff --git a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
index b9729ab9..8486327b 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
@@ -28,6 +28,8 @@ function requestTableForServer(srvId, suiteId, element) {
         success:
             function (result) {
                 showContributionsTable(result, srvId, suiteId)
+                fillBranchAutocompleteList(result, srvId);
+                setAutocompleteFilter();
             }
     });
 }
diff --git a/ignite-tc-helper-web/src/main/webapp/prs.html b/ignite-tc-helper-web/src/main/webapp/prs.html
index 48617c7d..668d3e31 100644
--- a/ignite-tc-helper-web/src/main/webapp/prs.html
+++ b/ignite-tc-helper-web/src/main/webapp/prs.html
@@ -63,7 +63,6 @@
                     $("#loadStatus").html("");
                     showSuitesForTeamCityRunData(result);
                     showFormAndSuitesForPrCheck(result);
-                    tryToFillAutocompleteLists();
                     showCommentJiraForm(result);
 
                     for (let chainAtServer of result)
@@ -71,14 +70,6 @@
                 },
                 error: showErrInLoadStatus
             });
-
-            $.ajax({
-                url: "rest/branches/getServerIds",
-                success:
-                    function (result) {
-                        setupAutocompleteList(result);
-                    }
-            });
         }
 
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services