Title: [188172] trunk/Tools
Revision
188172
Author
[email protected]
Date
2015-08-07 16:10:59 -0700 (Fri, 07 Aug 2015)

Log Message

Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic
https://bugs.webkit.org/show_bug.cgi?id=147667

Patch by Jason Marcell <[email protected]> on 2015-08-07
Reviewed by Daniel Bates.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:
(BuildbotQueue.prototype.compareIterations): Refactored to work more generically with repositories
other than "openSource" and "internal".
(BuildbotQueue.prototype.compareIterationsByRevisions): Ditto.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Dashboard.js:
(Dashboard.get sortedPlatforms): Added. Returns a sorted array of platforms.
(Dashboard.get sortedRepositories): Added. Returns a sorted array of repositories.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Main.js:
(documentReady): Using Dashboard.sortedPlatforms instead of sortedPlatforms.
(sortedPlatforms): Deleted.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/MetricsMain.js:
(buildQueuesTable): Using Dashboard.sortedPlatforms instead of sortedPlatforms.
(sortedPlatforms): Deleted.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Utilities.js:
(sortDictionariesByOrder): Added. Takes an array of dictionaries that have an "order" property
and sorts them by this property returning the new sorted array.

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js (188171 => 188172)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js	2015-08-07 23:07:22 UTC (rev 188171)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js	2015-08-07 23:10:59 UTC (rev 188172)
@@ -268,14 +268,14 @@
 
     compareIterations: function(a, b)
     {
-        var result = b.revision[Dashboard.Repository.OpenSource.name] - a.revision[Dashboard.Repository.OpenSource.name];
-        if (result)
-            return result;
+        var sortedRepositories = Dashboard.sortedRepositories;
+        for (var i = 0; i < sortedRepositories.length; ++i) {
+            var repositoryName = sortedRepositories[i].name;
+            var result = b.revision[repositoryName] - a.revision[repositoryName];
+            if (result)
+                return result;
+        }
 
-        result = b.revision[Dashboard.Repository.Internal.name] - a.revision[Dashboard.Repository.Internal.name];
-        if (result)
-            return result;
-
         // A loaded iteration may not have revision numbers if it failed early, before svn steps finished.
         result = b.loaded - a.loaded;
         if (result)
@@ -286,14 +286,14 @@
 
     compareIterationsByRevisions: function(a, b)
     {
-        var result = b.revision[Dashboard.Repository.OpenSource.name] - a.revision[Dashboard.Repository.OpenSource.name];
-        if (result)
-            return result;
+        var sortedRepositories = Dashboard.sortedRepositories;
+        for (var i = 0; i < sortedRepositories.length; ++i) {
+            var repositoryName = sortedRepositories[i].name;
+            var result = b.revision[repositoryName] - a.revision[repositoryName];
+            if (result)
+                return result;
+        }
 
-        result = b.revision[Dashboard.Repository.Internal.name] - a.revision[Dashboard.Repository.Internal.name];
-        if (result)
-            return result;
-
         return 0;
     },
 

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Dashboard.js (188171 => 188172)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Dashboard.js	2015-08-07 23:07:22 UTC (rev 188171)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Dashboard.js	2015-08-07 23:10:59 UTC (rev 188172)
@@ -39,5 +39,17 @@
     Repository: {
         OpenSource: { name: "openSource", order: 0 },
         Internal: { name: "internal", order: 1 },
-    }
+    },
+    get sortedPlatforms()
+    {
+        if (!this._sortedPlatforms)
+            this._sortedPlatforms = sortDictionariesByOrder(Dashboard.Platform);
+        return this._sortedPlatforms;
+    },
+    get sortedRepositories()
+    {
+        if (!this._sortedRepositories)
+            this._sortedRepositories = sortDictionariesByOrder(Dashboard.Repository);
+        return this._sortedRepositories;
+    },
 };

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Main.js (188171 => 188172)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Main.js	2015-08-07 23:07:22 UTC (rev 188171)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Main.js	2015-08-07 23:10:59 UTC (rev 188172)
@@ -103,20 +103,6 @@
 testNames[Buildbot.TestCategory.WebKit2] = "WK2 Tests";
 testNames[Buildbot.TestCategory.WebKit1] = "WK1 Tests";
 
-function sortedPlatforms()
-{
-    var platforms = [];
-
-    for (var platformKey in Dashboard.Platform)
-        platforms.push(Dashboard.Platform[platformKey]);
-
-    platforms.sort(function(a, b) {
-        return a.order - b.order;
-    });
-
-    return platforms;
-}
-
 function updateHiddenPlatforms()
 {
     var hiddenPlatforms = settings.getObject("hiddenPlatforms");
@@ -199,7 +185,7 @@
 
     table.appendChild(row);
 
-    var platforms = sortedPlatforms();
+    var platforms = Dashboard.sortedPlatforms;
 
     for (var i in platforms) {
         var platform = platforms[i];

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/MetricsMain.js (188171 => 188172)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/MetricsMain.js	2015-08-07 23:07:22 UTC (rev 188171)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/MetricsMain.js	2015-08-07 23:10:59 UTC (rev 188172)
@@ -70,20 +70,6 @@
 testNames[Buildbot.TestCategory.WebKit2] = "WK2 Tests";
 testNames[Buildbot.TestCategory.WebKit1] = "WK1 Tests";
 
-function sortedPlatforms()
-{
-    var platforms = [];
-
-    for (var platformKey in Dashboard.Platform)
-        platforms.push(Dashboard.Platform[platformKey]);
-
-    platforms.sort(function(a, b) {
-        return a.order - b.order;
-    });
-
-    return platforms;
-}
-
 function updateHiddenPlatforms()
 {
     var hiddenPlatforms = settings.getObject("hiddenPlatforms");
@@ -204,7 +190,7 @@
 
     table.appendChild(row);
 
-    var platforms = sortedPlatforms();
+    var platforms = Dashboard.sortedPlatforms;
 
     for (var i in platforms) {
         var platform = platforms[i];

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Utilities.js (188171 => 188172)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Utilities.js	2015-08-07 23:07:22 UTC (rev 188171)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Utilities.js	2015-08-07 23:10:59 UTC (rev 188172)
@@ -196,4 +196,18 @@
 String.prototype.startsWith = function(substring)
 {
     return this.lastIndexOf(substring, 0) === 0;
-}
+};
+
+function sortDictionariesByOrder(unsorted)
+{
+    var sorted = [];
+
+    for (var key in unsorted)
+        sorted.push(unsorted[key]);
+
+    sorted.sort(function(a, b) {
+        return a.order - b.order;
+    });
+
+    return sorted;
+};

Modified: trunk/Tools/ChangeLog (188171 => 188172)


--- trunk/Tools/ChangeLog	2015-08-07 23:07:22 UTC (rev 188171)
+++ trunk/Tools/ChangeLog	2015-08-07 23:10:59 UTC (rev 188172)
@@ -1,3 +1,27 @@
+2015-08-07  Jason Marcell  <[email protected]>
+
+        Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic
+        https://bugs.webkit.org/show_bug.cgi?id=147667
+
+        Reviewed by Daniel Bates.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:
+        (BuildbotQueue.prototype.compareIterations): Refactored to work more generically with repositories
+        other than "openSource" and "internal".
+        (BuildbotQueue.prototype.compareIterationsByRevisions): Ditto.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Dashboard.js:
+        (Dashboard.get sortedPlatforms): Added. Returns a sorted array of platforms.
+        (Dashboard.get sortedRepositories): Added. Returns a sorted array of repositories.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Main.js:
+        (documentReady): Using Dashboard.sortedPlatforms instead of sortedPlatforms.
+        (sortedPlatforms): Deleted.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/MetricsMain.js:
+        (buildQueuesTable): Using Dashboard.sortedPlatforms instead of sortedPlatforms.
+        (sortedPlatforms): Deleted.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Utilities.js:
+        (sortDictionariesByOrder): Added. Takes an array of dictionaries that have an "order" property
+        and sorts them by this property returning the new sorted array.
+
 2015-08-07  Filip Pizlo  <[email protected]>
 
         Lightweight locks should be adaptive
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to