<?php

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once "../internals.php";
require_once "../lib/DB/Regression.php";
require_once "../lib/VersionControl.php";
init_database();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$id = (int) $request->id;
$regression = Regression::FromId($id);
$build = $regression->build() or throw_exception("Couldn't retrieve the build of regression {$id}.");
$prev_build = $regression->prev_build() or throw_exception("Couldn't retrieve the prev_build of regression {$id}.");
$regression->build()->revision();
$regression->prev_build()->revision();
$versionControl = VersionControl::forMode($build->mode_id());
$revisions = $versionControl->revisions($prev_build->revision(), $build->revision());
$data = array();
foreach ($revisions as $revision) {
    $data[] = array("author" => $revision->author, "date" => $revision->date, "revision" => $revision->revision, "message" => $revision->message);
}
echo json_encode($data);
<?php

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once "../internals.php";
init_database();
require_once "data-func.php";
require_once "../lib/RetriggerController.php";
require_once "../lib/DB/Regression.php";
require_once "../lib/RegressionTools.php";
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$regression = Regression::FromId((int) $request->id);
$inbetween = array();
foreach (RegressionTools::inbetweenBuilds($regression) as $build) {
    $inbetween[] = $build->revision();
}
echo json_encode($inbetween);
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$ids = array();
$single = true;
if (isset($request->ids)) {
    for ($i = 0; $i < count($request->ids); $i++) {
        $ids[] = (int) $request->ids[$i];
    }
    $single = false;
} else {
    $ids[] = (int) $request->id;
}
$minimal = isset($request->minimal) ? !!$request->minimal : false;
$data = array();
for ($i = 0; $i < count($ids); $i++) {
    $db_regression = Regression::FromId($ids[$i]);
    if (!$db_regression) {
        $data[] = array();
        continue;
    }
    $db_build = $db_regression->build();
    $db_run = $db_build->run();
    $db_prev_build = $db_regression->prev_build();
    $regression = array("id" => $db_regression->id, "machine" => $db_run->machine_id(), "mode" => $db_build->mode_id(), "stamp" => $db_run->finish_stamp(), "cset" => $db_build->revision(), "bug" => $db_regression->bug(), "status" => $db_regression->status(), "build_id" => $db_build->id, "detector" => $db_run->detector(), "run_id" => $db_run->id, "prev_run_id" => $db_prev_build->run_id(), "scores" => array(), "retriggerable" => RetriggerController::retriggerable($db_run->machine_id(), $db_build->mode_id()));
    $qScores = mysql_query("SELECT * FROM awfy_regression_score\n\t\t\t\t\t\t    WHERE regression_id = '" . $regression["id"] . "'") or die(mysql_error());
    while ($scores = mysql_fetch_assoc($qScores)) {
        $suite_version_id = get("score", $scores["score_id"], "suite_version_id");
        $score = array("score_id" => $scores["score_id"], "suite_version" => $suite_version_id, "score" => get("score", $scores["score_id"], "score"), "noise" => $scores["noise"]);
        $qPrevScore = mysql_query("SELECT score\n\t\t\t\t\t\t\t\t   FROM awfy_score\n\t\t\t\t\t\t\t\t   WHERE build_id = " . $db_prev_build->id . " AND\n\t\t\t\t\t\t\t\t\t\t suite_version_id = " . $suite_version_id . "\n\t\t\t\t\t\t\t\t   LIMIT 1") or die(mysql_error());
        if (mysql_num_rows($qPrevScore) == 1) {
            $prevScore = mysql_fetch_assoc($qPrevScore);
 /**
  * Have the parent separate the points into xs and ys.
  * Calculate the regression parameters
  */
 public function __construct(array $points)
 {
     parent::__construct($points);
     $this->calculate();
 }