2013-03-21 16:04:29 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorTokenReceiverQuery
|
|
|
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
|
|
|
|
|
|
|
private $tokenCounts;
|
|
|
|
|
|
|
|
protected function loadPage() {
|
|
|
|
$table = new PhabricatorTokenCount();
|
|
|
|
$conn_r = $table->establishConnection('r');
|
|
|
|
|
|
|
|
$rows = queryfx_all(
|
|
|
|
$conn_r,
|
|
|
|
'SELECT objectPHID, tokenCount FROM %T ORDER BY tokenCount DESC',
|
|
|
|
$table->getTableName());
|
|
|
|
|
|
|
|
$this->tokenCounts = ipull($rows, 'tokenCount', 'objectPHID');
|
|
|
|
return ipull($rows, 'objectPHID');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function willFilterPage(array $phids) {
|
|
|
|
$objects = id(new PhabricatorObjectHandleData($phids))
|
|
|
|
->setViewer($this->getViewer())
|
|
|
|
->loadObjects();
|
2013-03-22 12:25:00 -07:00
|
|
|
|
|
|
|
// Reorder the objects in the input order.
|
|
|
|
$objects = array_select_keys($objects, $phids);
|
|
|
|
|
2013-03-21 16:04:29 -07:00
|
|
|
return $objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTokenCounts() {
|
|
|
|
return $this->tokenCounts;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|