Fix the link noted 'contribute to features' in status.html
[WebKit-https.git] / Websites / perf.webkit.org / public / api / triggerables.php
1 <?php
2
3 require('../include/json-header.php');
4
5 function main($path) {
6     if (count($path) > 1)
7         exit_with_error('InvalidRequest');
8
9     $db = new Database;
10     if (!$db->connect())
11         exit_with_error('DatabaseConnectionFailure');
12
13     $task_id = array_get($_GET, 'task');
14     $query = array();
15     if ($task_id) {
16         $triggerable = find_triggerable_for_task($db, $task_id);
17         if (!$triggerable)
18             exit_with_error('TriggerableNotFoundForTask', array('task' => $task_id));
19         $query['id'] = $triggerable['id'];
20     }
21
22     $id_to_triggerable = array();
23     foreach ($db->select_rows('build_triggerables', 'triggerable', $query) as $row) {
24         $id = $row['triggerable_id'];
25         $repositories = array();
26         $id_to_triggerable[$id] = array('id' => $id, 'name' => $row['triggerable_name'], 'acceptedRepositories' => &$repositories);
27     }
28
29     foreach ($db->select_rows('triggerable_repositories', 'trigrepo', array()) as $row) {
30         $triggerable = array_get($id_to_triggerable, $row['trigrepo_triggerable']);
31         if ($triggerable)
32             array_push($triggerable['acceptedRepositories'], $row['trigrepo_repository']);
33     }
34
35     exit_with_success(array('triggerables' => array_values($id_to_triggerable)));
36 }
37
38 main(array_key_exists('PATH_INFO', $_SERVER) ? explode('/', trim($_SERVER['PATH_INFO'], '/')) : array());
39
40 ?>