/**
  * @brief Saves reports as `PerformanceMetric` in the database.
  *
  * @uses PerformanceAuditManager::Save()
  * @see XHProfPerformanceAuditor->generateReport()
  *
  * @return {Null}
  *
  * @author <*****@*****.**>
  * @date 02/19/2014
  */
 public function save($report = null)
 {
     if (is_array($report)) {
         $report = array_merge($report, array("source" => self::ID, "realm" => self::REALM));
         PerformanceAuditManager::Save($report);
         return $report;
     } else {
         foreach ($this->_reports as $report) {
             $report = array_merge($report, array("source" => self::ID, "realm" => self::REALM));
             PerformanceAuditManager::Save($report);
         }
         return $this->_reports;
     }
 }
Пример #2
0
<?php

require_once dirname(__FILE__) . "/../lib/PerformanceAuditManager.php";
if (isset($_REQUEST["source"])) {
    if (is_array($auditors)) {
        $auditors = $_REQUEST["source"];
    } else {
        $auditors = array($_REQUEST["source"]);
    }
} else {
    $auditors = array("BoomerangPerformanceAuditor");
}
$auditors = $_REQUEST["source"];
$apiResults = array("data" => null, "status" => array("code" => 0, "message" => "Success"));
$pa = new PerformanceAuditManager($auditors);
$results = $pa->getAudits(array("from" => $_REQUEST["from"], "to" => $_REQUEST["to"]));
error_log(var_export($results, true));
$apiResults["data"]["totals"] = $results["totals"];
foreach ($results["audits"] as $auditor => $report) {
    error_log("Gettings reports for: " . $auditor . " who has " . $report["total"] . " reports");
    foreach ($report["reports"] as $audit) {
        $apiResults["data"]["realms"][$audit->getValue("realm")][$auditor][] = $audit->generateStats(true);
    }
}
echo json_encode($apiResults);
 /**
  * @brief Logs a failure.
  *
  * ## Overview
  * Used for aborting this audit and reporting what caused the failure. Used in cases such as when
  * the `PerformanceAuditManager::MAX_AUDITS_PER_ACCOUNT` limit has been met.
  *
  * @uses PerformanceAuditManager::Log()
  *
  * @param {String} $errorCode Code to set status too, also passed to Log method as key for error message.
  * @param {Array} $errorData Extra data pertaining to failure.
  *
  * @return {Boolean} True always.
  *
  * @author <*****@*****.**>
  * @date 02/19/2014
  */
 public static function Fail($errorCode = -1, $errorData = null)
 {
     self::$status = $errorCode;
     return self::Log(self::DEBUG_LEVEL_ERROR, $errorCode, $errorData);
 }