Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorFactChartFunction.php
Show All 29 Lines | public function loadData() { | ||||
if (!$key_id) { | if (!$key_id) { | ||||
return; | return; | ||||
} | } | ||||
$table = $fact->newDatapoint(); | $table = $fact->newDatapoint(); | ||||
$conn = $table->establishConnection('r'); | $conn = $table->establishConnection('r'); | ||||
$table_name = $table->getTableName(); | $table_name = $table->getTableName(); | ||||
$data = queryfx_all( | $where = array(); | ||||
$where[] = qsprintf( | |||||
$conn, | $conn, | ||||
'SELECT value, epoch FROM %T WHERE keyID = %d ORDER BY epoch ASC', | 'keyID = %d', | ||||
$table_name, | |||||
$key_id); | $key_id); | ||||
if (!$data) { | |||||
return; | $parser = $this->getArgumentParser(); | ||||
$parts = $fact->buildWhereClauseParts($conn, $parser); | |||||
foreach ($parts as $part) { | |||||
$where[] = $part; | |||||
} | } | ||||
$data = queryfx_all( | |||||
$conn, | |||||
'SELECT value, epoch FROM %T WHERE %LA ORDER BY epoch ASC', | |||||
$table_name, | |||||
$where); | |||||
$map = array(); | $map = array(); | ||||
if ($data) { | |||||
foreach ($data as $row) { | foreach ($data as $row) { | ||||
$value = (int)$row['value']; | $value = (int)$row['value']; | ||||
$epoch = (int)$row['epoch']; | $epoch = (int)$row['epoch']; | ||||
if (!isset($map[$epoch])) { | if (!isset($map[$epoch])) { | ||||
$map[$epoch] = 0; | $map[$epoch] = 0; | ||||
} | } | ||||
$map[$epoch] += $value; | $map[$epoch] += $value; | ||||
} | } | ||||
} | |||||
$this->map = $map; | $this->map = $map; | ||||
} | } | ||||
public function getDomain() { | public function getDomain() { | ||||
return array( | return array( | ||||
head_key($this->map), | head_key($this->map), | ||||
last_key($this->map), | last_key($this->map), | ||||
Show All 24 Lines |