7077e52789a230fd5f5c6c0f92a860a8b086f136
[WebKit-https.git] / Websites / perf.webkit.org / public / v3 / models / build-request.js
1 'use strict';
2
3 class BuildRequest extends DataModelObject {
4
5     constructor(id, object)
6     {
7         super(id, object);
8         console.assert(!object.testGroup || object.testGroup instanceof TestGroup);
9         this._testGroup = object.testGroup;
10         if (this._testGroup)
11             this._testGroup.addBuildRequest(this);
12         this._order = object.order;
13         console.assert(object.rootSet instanceof RootSet);
14         this._rootSet = object.rootSet;
15         this._status = object.status;
16         this._statusUrl = object.url;
17         this._buildId = object.build;
18         this._result = null;
19     }
20
21     updateSingleton(object)
22     {
23         console.assert(this._testGroup == object.testGroup);
24         console.assert(this._order == object.order);
25         console.assert(this._rootSet == object.rootSet);
26         this._status = object.status;
27         this._statusUrl = object.url;
28         this._buildId = object.build;
29     }
30
31     testGroup() { return this._testGroup; }
32     order() { return this._order; }
33     rootSet() { return this._rootSet; }
34
35     hasFinished() { return this._status == 'failed' || this._status == 'completed' || this._status == 'canceled'; }
36     hasStarted() { return this._status != 'pending'; }
37     hasPending() { return this._status == 'pending'; }
38     statusLabel()
39     {
40         switch (this._status) {
41         case 'pending':
42             return 'Waiting to be scheduled';
43         case 'scheduled':
44             return 'Scheduled';
45         case 'running':
46             return 'Running';
47         case 'failed':
48             return 'Failed';
49         case 'completed':
50             return 'Completed';
51         case 'canceled':
52             return 'Canceled';
53         }
54     }
55     statusUrl() { return this._statusUrl; }
56
57     buildId() { return this._buildId; }
58
59     result() { return this._result; }
60     setResult(result)
61     {
62         this._result = result;
63         this._testGroup.didSetResult(this);
64     }
65 }
66
67 if (typeof module != 'undefined')
68     module.exports.BuildRequest = BuildRequest;