Title: [198923] trunk/Websites/perf.webkit.org
Revision
198923
Author
[email protected]
Date
2016-03-31 15:42:15 -0700 (Thu, 31 Mar 2016)

Log Message

Simplify API of Test model by removing Test.setParentTest
https://bugs.webkit.org/show_bug.cgi?id=156055

Reviewed by Joseph Pecoraro.

Removed Test.setParentTest. Keep track of the child-parent relationship using the static map instead.

Now each test only stores parent's id and uses the ID static map in Test.parentTest().

* public/v3/models/manifest.js:
(Manifest._didFetchManifest.buildObjectsFromIdMap): Removed the code to create the map of child-parent
relationship and call setParentTest.
* public/v3/models/test.js:
(Test): Updated a static map by the name of "childTestMap" to store itself. We should probably sort
child tests using some fixed criteria in the future instead of relying on the creation order but
preserve the old code's ordering for now.
(Test.prototype.parentTest): Look up the static map by the parent test's id.
(Test.prototype.onlyContainsSingleMetric):
(Test.prototype.setParentTest): Deleted.
(Test.prototype.childTests): Look up the child test map.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (198922 => 198923)


--- trunk/Websites/perf.webkit.org/ChangeLog	2016-03-31 22:38:20 UTC (rev 198922)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2016-03-31 22:42:15 UTC (rev 198923)
@@ -1,5 +1,28 @@
 2016-03-30  Ryosuke Niwa  <[email protected]>
 
+        Simplify API of Test model by removing Test.setParentTest
+        https://bugs.webkit.org/show_bug.cgi?id=156055
+
+        Reviewed by Joseph Pecoraro.
+
+        Removed Test.setParentTest. Keep track of the child-parent relationship using the static map instead.
+
+        Now each test only stores parent's id and uses the ID static map in Test.parentTest().
+
+        * public/v3/models/manifest.js:
+        (Manifest._didFetchManifest.buildObjectsFromIdMap): Removed the code to create the map of child-parent
+        relationship and call setParentTest.
+        * public/v3/models/test.js:
+        (Test): Updated a static map by the name of "childTestMap" to store itself. We should probably sort
+        child tests using some fixed criteria in the future instead of relying on the creation order but
+        preserve the old code's ordering for now.
+        (Test.prototype.parentTest): Look up the static map by the parent test's id.
+        (Test.prototype.onlyContainsSingleMetric):
+        (Test.prototype.setParentTest): Deleted.
+        (Test.prototype.childTests): Look up the child test map.
+
+2016-03-30  Ryosuke Niwa  <[email protected]>
+
         BuildRequest should have associated platform and test
         https://bugs.webkit.org/show_bug.cgi?id=156054
 

Modified: trunk/Websites/perf.webkit.org/public/v3/models/manifest.js (198922 => 198923)


--- trunk/Websites/perf.webkit.org/public/v3/models/manifest.js	2016-03-31 22:38:20 UTC (rev 198922)
+++ trunk/Websites/perf.webkit.org/public/v3/models/manifest.js	2016-03-31 22:42:15 UTC (rev 198923)
@@ -15,15 +15,8 @@
 
         var tests = [];
         var testParentMap = {};
-        for (var testId in rawResponse.tests) {
-            var test = rawResponse.tests[testId];
-            var topLevel = !test.parentId;
-            if (test.parentId)
-                testParentMap[testId] = parseInt(test.parentId);
-            tests.push(new Test(testId, test, topLevel));
-        }
-        for (var testId in testParentMap)
-            Test.findById(testId).setParentTest(Test.findById(testParentMap[testId]));
+        for (var testId in rawResponse.tests)
+            tests.push(new Test(testId, rawResponse.tests[testId]));
 
         function buildObjectsFromIdMap(idMap, constructor, resolver) {
             for (var id in idMap) {

Modified: trunk/Websites/perf.webkit.org/public/v3/models/test.js (198922 => 198923)


--- trunk/Websites/perf.webkit.org/public/v3/models/test.js	2016-03-31 22:38:20 UTC (rev 198922)
+++ trunk/Websites/perf.webkit.org/public/v3/models/test.js	2016-03-31 22:42:15 UTC (rev 198923)
@@ -1,21 +1,28 @@
 'use strict';
 
 class Test extends LabeledObject {
-    constructor(id, object, isTopLevel)
+    constructor(id, object)
     {
         super(id, object);
         this._url = object.url; // FIXME: Unused
-        this._parent = null;
+        this._parentId = object.parentId;
         this._childTests = [];
         this._metrics = [];
 
-        if (isTopLevel)
+        if (!this._parentId)
             this.ensureNamedStaticMap('topLevelTests')[id] = this;
+        else {
+            var childMap = this.ensureNamedStaticMap('childTestMap');
+            if (!childMap[this._parentId])
+                childMap[this._parentId] = [this];
+            else
+                childMap[this._parentId].push(this);
+        }
     }
 
     static topLevelTests() { return this.sortByName(this.listForStaticMap('topLevelTests')); }
 
-    parentTest() { return this._parent; }
+    parentTest() { return Test.findById(this._parentId); }
 
     path()
     {
@@ -28,18 +35,16 @@
         return path;
     }
 
-    onlyContainsSingleMetric() { return !this._childTests.length && this._metrics.length == 1; }
+    onlyContainsSingleMetric() { return !this.childTests().length && this._metrics.length == 1; }
 
-    // FIXME: We should store the child test order in the server.
-    childTests() { return this._childTests; }
-    metrics() { return this._metrics; }
-
-    setParentTest(parent)
+    childTests()
     {
-        parent.addChildTest(this);
-        this._parent = parent;
+        var childMap = this.namedStaticMap('childTestMap');
+        return childMap && this.id() in childMap ? childMap[this.id()] : [];
     }
 
+    metrics() { return this._metrics; }
+
     addChildTest(test) { this._childTests.push(test); }
     addMetric(metric) { this._metrics.push(metric); }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to