0ac39d57ae51509758bac2ca160d8ac0ab69097d
[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 instanceof TestGroup);
9         this._testGroup = object.testGroup;
10         this._testGroup.addBuildRequest(this);
11         this._order = object.order;
12         console.assert(object.rootSet instanceof RootSet);
13         this._rootSet = object.rootSet;
14         this._status = object.status;
15         this._statusUrl = object.url;
16         this._buildId = object.build;
17         this._result = null;
18     }
19
20     updateSingleton(object)
21     {
22         console.assert(this._testGroup == object.testGroup);
23         console.assert(this._order == object.order);
24         console.assert(this._rootSet == object.rootSet);
25         this._status = object.status;
26         this._statusUrl = object.url;
27         this._buildId = object.build;
28     }
29
30     testGroup() { return this._testGroup; }
31     order() { return this._order; }
32     rootSet() { return this._rootSet; }
33
34     hasFinished() { return this._status == 'failed' || this._status == 'completed' || this._status == 'canceled'; }
35     hasStarted() { return this._status != 'pending'; }
36     hasPending() { return this._status == 'pending'; }
37     statusLabel()
38     {
39         switch (this._status) {
40         case 'pending':
41             return 'Waiting to be scheduled';
42         case 'scheduled':
43             return 'Scheduled';
44         case 'running':
45             return 'Running';
46         case 'failed':
47             return 'Failed';
48         case 'completed':
49             return 'Completed';
50         case 'canceled':
51             return 'Canceled';
52         }
53     }
54     statusUrl() { return this._statusUrl; }
55
56     buildId() { return this._buildId; }
57
58     result() { return this._result; }
59     setResult(result)
60     {
61         this._result = result;
62         this._testGroup.didSetResult(this);
63     }
64 }
65
66 if (typeof module != 'undefined')
67     module.exports.BuildRequest = BuildRequest;