56408823478c9a26222b0a6e34b6b48329db100f
[WebKit-https.git] / Tools / BuildSlaveSupport / build.webkit.org-config / public_html / dashboard / Scripts / BubbleQueueServer.js
1 /*
2  * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 BubbleQueueServer = function()
27 {
28     const queueInfo = {
29         "commit-queue": {platform: Dashboard.Platform.MacOSXYosemite, shortName: "commit", title: "Commit Queue"},
30         "style-queue": {shortName: "style", title: "Style Checker Queue"},
31         "gtk-wk2-ews": {platform: Dashboard.Platform.LinuxGTK, shortName: "gtk-wk2", title: "WebKit2\xa0Release\xa0Build\xa0EWS"},
32         "ios-ews": {platform: Dashboard.Platform.iOS9Device, shortName: "ios", title: "WebKit\xa0Release\xa0Build\xa0EWS"},
33         "mac-ews": {platform: Dashboard.Platform.MacOSXYosemite, shortName: "mac", title: "WebKit1\xa0Release\xa0Tests\xa0EWS"},
34         "mac-wk2-ews": {platform: Dashboard.Platform.MacOSXYosemite, shortName: "mac-wk2", title: "WebKit2\xa0Release\xa0Tests\xa0EWS"},
35         "mac-debug-ews": {platform: Dashboard.Platform.MacOSXYosemite, shortName: "mac-debug", title: "WebKit1\xa0Debug\xa0Tests\xa0EWS"},
36         "mac-32bit-ews": {platform: Dashboard.Platform.MacOSXYosemite, shortName: "mac-32bit", title: "Release\xa032\u2011bit\xa0Build\xa0EWS"},
37         "win-ews": {platform: Dashboard.Platform.Windows7, shortName: "win", title: "WebKit1\xa0Release\xa0Build\xa0EWS"},
38         "efl-wk2-ews": {platform: Dashboard.Platform.LinuxEFL, shortName: "efl-wk2", title: "WebKit2\xa0Release\xa0Build\xa0EWS"}
39     };
40
41     BaseObject.call(this);
42
43     this.baseURL = "https://webkit-queues.webkit.org/";
44     this.queues = {};
45
46     for (var id in queueInfo)
47         this.queues[id] = new BubbleQueue(this, id, queueInfo[id]);
48 };
49
50 BaseObject.addConstructorFunctions(BubbleQueueServer);
51
52 BubbleQueueServer.prototype = {
53     constructor: BubbleQueueServer,
54     __proto__: BaseObject.prototype,
55
56     jsonQueueLengthURL: function(queueID)
57     {
58         return this.baseURL + "queue-length-json/" + encodeURIComponent(queueID);
59     },
60
61     jsonQueueStatusURL: function(queueID)
62     {
63         return this.baseURL + "queue-status-json/" + encodeURIComponent(queueID);
64     },
65
66     jsonProcessingTimesURL: function(fromTime, toTime)
67     {
68         return this.baseURL + "processing-times-json/" + [fromTime.getUTCFullYear(), fromTime.getUTCMonth() + 1, fromTime.getUTCDate(), fromTime.getUTCHours(), fromTime.getUTCMinutes(), fromTime.getUTCSeconds()].join("-")
69             + "-" + [toTime.getUTCFullYear(), toTime.getUTCMonth() + 1, toTime.getUTCDate(), toTime.getUTCHours(), toTime.getUTCMinutes(), toTime.getUTCSeconds()].join("-");
70     },
71
72     queueStatusURL: function(queueID)
73     {
74         return this.baseURL + "queue-status/" + encodeURIComponent(queueID);
75     },
76
77     // Retrieves information about all patches that were submitted in the time range:
78     // {
79     //     patch_id_1: {
80     //         queue_name_1: {
81     //             date: <date/time when the patch was submitted to the queue>,
82     //             retry_count: <number of times a bot had to bail out and drop the lock, for another bot to start from scratch>,
83     //             wait_duration: <how long it took before a bot first locked the patch for processing>,
84     //             process_duration: <how long it took from end of wait to finish, only valid for finished patches. Includes wait time between retries>
85     //             final_message: <(pass|fail|not processed|could not apply|internal error|in progress)>
86     //         },
87     //         ...
88     //     },
89     //     ...
90     // }
91     loadProcessingTimes: function(fromTime, toTime, callback)
92     {
93         JSON.load(this.jsonProcessingTimesURL(fromTime, toTime), function(data) {
94             for (patch in data) {
95                 for (queue in patch)
96                     queue.date = new Date(queue.date);
97             }
98             callback(data, fromTime, toTime);
99         }.bind(this));
100     },
101 };