8cf2b5bdfb738fbeff7e263f2be5f2b457bf30d9
[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 $result_rows = $db->query_and_fetch_all(
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 results.actual != $2 AND builds.start_time > now() - interval \'' . $number_of_days . ' days\'
27     GROUP BY results.id, builds.id', array($builder_id, 'PASS'));
28 if (!$result_rows)
29     exit_with_error('ResultsNotFound');
30
31 exit_with_success(format_result_rows($result_rows));
32
33 ?>