Add API to upload a patched build for a custom A/B testing
[WebKit.git] / Websites / perf.webkit.org / public / v3 / models / test-group.js
index c622619..7452a85 100644 (file)
@@ -32,6 +32,7 @@ class TestGroup extends LabeledObject {
         this._isHidden = object.hidden;
     }
 
+    task() { return AnalysisTask.findById(this._taskId); }
     createdAt() { return this._createdAt; }
     isHidden() { return this._isHidden; }
     buildRequests() { return this._buildRequests; }
@@ -199,7 +200,7 @@ class TestGroup extends LabeledObject {
         return PrivilegedAPI.sendRequest('create-test-group', params).then((data) => {
             return AnalysisTask.fetchById(data['taskId']);
         }).then((task) => {
-            return this._fetchTestGroupsForTask(task.id()).then(() => task);
+            return this.fetchForTask(task.id()).then(() => task);
         });
     }
 
@@ -209,7 +210,7 @@ class TestGroup extends LabeledObject {
         const revisionSets = this._revisionSetsFromCommitSets(commitSets);
         const params = {task: task.id(), name: groupName, platform: platform.id(), test: test.id(), repetitionCount, revisionSets};
         return PrivilegedAPI.sendRequest('create-test-group', params).then((data) => {
-            return this._fetchTestGroupsForTask(task.id());
+            return this.fetchForTask(task.id(), true);
         });
     }
 
@@ -222,7 +223,7 @@ class TestGroup extends LabeledObject {
             name: name,
             repetitionCount: repetitionCount,
             revisionSets: revisionSets,
-        }).then((data) => this._fetchTestGroupsForTask(task.id()));
+        }).then((data) => this.fetchForTask(task.id(), true));
     }
 
     static _revisionSetsFromCommitSets(commitSets)
@@ -244,14 +245,14 @@ class TestGroup extends LabeledObject {
         });
     }
 
-    static _fetchTestGroupsForTask(taskId)
+    static findAllByTask(taskId)
     {
-        return this.cachedFetch('/api/test-groups', {task: taskId}, true).then((data) => this._createModelsFromFetchedTestGroups(data));
+        return TestGroup.all().filter((testGroup) => testGroup._taskId == taskId);
     }
 
-    static fetchByTask(taskId)
+    static fetchForTask(taskId, ignoreCache = false)
     {
-        return this.cachedFetch('/api/test-groups', {task: taskId}).then(this._createModelsFromFetchedTestGroups.bind(this));
+        return this.cachedFetch('/api/test-groups', {task: taskId}, ignoreCache).then(this._createModelsFromFetchedTestGroups.bind(this));
     }
 
     static _createModelsFromFetchedTestGroups(data)