SomeFire commented on a change in pull request #25: IGNITE-9645 [TC Bot] Add 
comparison of failed tests lists in two date intervals
URL: https://github.com/apache/ignite-teamcity-bot/pull/25#discussion_r222289864
 
 

 ##########
 File path: ignite-tc-helper-web/src/main/webapp/comparison.html
 ##########
 @@ -173,6 +178,176 @@
         return parseFloat(string.substring(string.indexOf("-") + 2, 
string.lastIndexOf("-") - 1));
     }
 
+    var ch_disp = function(id) {
+        let el = document.getElementById(id);
+
+        el.style.display = el.style.display == 'block' ? 'none' : 'block';
+    }
+
+    function printTests(num, result) {
+        let obj = {};
+
+        try {
+            obj = JSON.parse(result);
+        } catch (e) {
+            showErrInLoadStatus
+
+            return;
+        }
+
+        if (obj == null)
+            return;
+
+        let tests = getTests(obj, num);
+
+        window.sessionStorage.setItem('tests' + num, tests);
+
+        $('#MT' + num).html(tests);
+    }
+
+    function compareHandler() {
+        var compareMode = window.sessionStorage.compareMode;
+
+        var needTestsUpdate = window.sessionStorage.needTestsUpdate;
+
+        if (needTestsUpdate == 'true') {
+            let result1 = window.sessionStorage.result1;
+
+            let result2 = window.sessionStorage.result2;
+
+            if (result1 == null || result2 == null) {
+                alert("Two columns should be loaded for compareMode!");
+
+                return;
+            }
+
+            let obj1 = {};
+
+            let obj2 = {};
+
+            try {
+                obj1 = JSON.parse(result1);
+
+                obj2 = JSON.parse(result2);
+            } catch (e) {
+                showErrInLoadStatus
+            }
+
+            window.sessionStorage.uniqTests1 = getUniqueTests(obj1, obj2, 1);
+
+            window.sessionStorage.uniqTests2 = getUniqueTests(obj2, obj1, 2);
+
+            window.sessionStorage.needTestsUpdate = 'false';
+        }
+
+        if (compareMode == 'true') {
+            $('#btt').html("CompareMode");
+
+            $('#MT1').html(window.sessionStorage.tests1);
+
+            $('#MT2').html(window.sessionStorage.tests2);
+
+            window.sessionStorage.compareMode = 'false';
+        } else {
+            $('#btt').html("FullMode");
+
+            $('#MT1').html(window.sessionStorage.uniqTests1);
+
+            $('#MT2').html(window.sessionStorage.uniqTests2);
+
+            window.sessionStorage.compareMode = 'true';
+        }
+
+    }
+
+    function getUniqueTests(obj1, obj2, num) {
+        let uniqObj = {};
+
+        let suites = Object.keys(obj1);
+
+        for (let suite of suites) {
+            if (!obj2.hasOwnProperty(suite)) {
+                uniqObj[suite] = obj1[suite];
+
+                continue;
+            }
+
+            let tests = obj2[suite];
+
+            let uniqTests = [];
+
+            for (let v of obj1[suite])
+                if (!tests.includes(v, 0))
+                    uniqTests.push(v);
+
+            if (uniqTests.length != 0)
+                uniqObj[suite] = uniqTests;
+        }
+
+        return getTests(uniqObj, num);
+    }
+
+    function getTests(obj, num) {
+        let res = '<body>';
+
+        let suites = Object.keys(obj).sort();
+
+        for (let suite of suites) {
+            let suiteName = suite.split('_').filter((value, index) => index != 
0).join('_');
+
+            res += '<div align="left" style="cursor: pointer" class="suite" 
onclick="ch_disp(\'' + suite + num + '\')"' +
+                '<p><b>' + suiteName + '</b>' + ' (' + obj[suite].length + 
')</p>' +
+                '</div>\n' +
+                '<div  id="' + suite + num + '"style="cursor: default; 
margin-left: 10px; display:none">';
+
+            for (let v of obj[suite].sort()) {
+                let list = v.toString().split(".");
+
+                if (list.length < 2)
+                    list = v.toString().split(":");
+
+                let testName = list.pop();
+
+                let testClass = list.pop();
+
+                res += '<p align="left" title="' + v + '">'
+                    + testClass + '.' + testName + ' ' +
+                    '<a href="#" onclick="getTestRef(\'' + v + '\')">' +
+                    '&gt&gt</a>' +
+                    '</p>'
+            }
+
+            res += '</div>';
+        }
+
+        res += '</body>';
+
+        return res;
+    }
+
+    function getTestRef(testName) {
+        let res = '';
+
+        $.ajax(
+            {
 
 Review comment:
   Move to previous line.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to