Fix the link noted 'contribute to features' in status.html
[WebKit-https.git] / Websites / perf.webkit.org / public / privileged-api / update-analysis-task.php
1 <?php
2
3 require_once('../include/json-header.php');
4
5 function main() {
6     $data = ensure_privileged_api_data_and_token();
7
8     $analysis_task_id = array_get($data, 'task');
9     if (!$analysis_task_id)
10         exit_with_error('AnalysisTaskNotSpecified');
11
12     $values = array();
13
14     if (array_key_exists('result', $data)) {
15         require_match_one_of_values('Result', $data['result'], array(null, 'progression', 'regression', 'unchanged', 'inconclusive'));
16         $values['result'] = $data['result'];
17     }
18
19     if (array_key_exists('needed', $data)) {
20         $needed = $data['needed'];
21         if ($needed === null)
22             $values['needed'] = null;
23         else if (in_array($needed, array(0, false)))
24             $values['needed'] = Database::to_database_boolean(false);
25         else if (in_array($needed, array(1, true)))
26             $values['needed'] = Database::to_database_boolean(true);
27         else
28             exit_with_error('InvalidValueForFeedback', array('value' => $data['needed']));
29     }
30
31     if (!$values)
32         exit_with_error('NothingToUpdate');
33
34     $db = connect();
35     $db->begin_transaction();
36
37     if (!$db->update_row('analysis_tasks', 'task', array('id' => $analysis_task_id), $values)) {
38         $db->rollback_transaction();
39         exit_with_error('FailedToUpdateTask', array('id' => $analysis_task_id, 'values' => $values));
40     }
41
42     $db->commit_transaction();
43
44     exit_with_success();
45 }
46
47 main();
48
49 ?>