New flakiness dashboard show test time, modifiers, and flaky tests
[WebKit-https.git] / Websites / test-results / api / failing-tests.php
1 <?php
2
3 require_once('../include/json-shared.php');
4 require_once('../include/test-results.php');
5
6 $db = connect();
7
8 require_existence_of($_GET, array('builder' => '/^[A-Za-z0-9 \(\)\-_]+$/'));
9 $builder_name = $_GET['builder'];
10 $number_of_days = array_get($_GET, 'days');
11 if ($number_of_days) {
12     require_format('number_of_days', $number_of_days, '/^[0-9]+$/');
13     $number_of_days = intval($number_of_days);
14 } else
15     $number_of_days = 3;
16
17 $builder_row = $db->select_first_row('builders', NULL, array('name' => $builder_name));
18 if (!$builder_row)
19     exit_with_error('BuilderNotFound');
20 $builder_id = $builder_row['id'];
21
22 $all_results = $db->query(
23 "SELECT results.*, builds.*, array_agg((build_revisions.repository, build_revisions.value, build_revisions.time)) AS revisions
24     FROM results, builds, build_revisions
25     WHERE build_revisions.build = builds.id AND results.build = builds.id AND builds.builder = $1
26     AND builds.start_time > now() - interval '$number_of_days days'
27     GROUP BY results.id, builds.id ORDER BY results.test, max(build_revisions.time) DESC", array($builder_id));
28
29 if (!$all_results)
30     exit_with_error('ResultsNotFound');
31
32 // To conserve memory, we serialize tests at a time.
33 echo "{\"status\": \"OK\", \"builders\": {\"$builder_id\":{";
34 $currentTest = NULL;
35 $i = 0;
36 while ($result = $db->fetch_next_row($all_results)) {
37     if ($result['test'] != $currentTest) {
38         if ($currentTest)
39             echo '],';
40         $currentTest = $result['test'];
41         echo "\"$currentTest\": [";
42     } else
43         echo ',';
44     echo json_encode(format_result($result), true);
45 }
46 if ($currentTest)
47     echo ']';
48 echo '}}}';
49
50 ?>