Path: blob/master/src/applications/diffusion/query/DiffusionSyncLogSearchEngine.php
12242 views
<?php12final class DiffusionSyncLogSearchEngine3extends PhabricatorApplicationSearchEngine {45public function getResultTypeDescription() {6return pht('Sync Logs');7}89public function getApplicationClassName() {10return 'PhabricatorDiffusionApplication';11}1213public function newQuery() {14return new PhabricatorRepositorySyncEventQuery();15}1617protected function buildQueryFromParameters(array $map) {18$query = $this->newQuery();1920if ($map['repositoryPHIDs']) {21$query->withRepositoryPHIDs($map['repositoryPHIDs']);22}2324if ($map['createdStart'] || $map['createdEnd']) {25$query->withEpochBetween(26$map['createdStart'],27$map['createdEnd']);28}2930return $query;31}3233protected function buildCustomSearchFields() {34return array(35id(new PhabricatorSearchDatasourceField())36->setDatasource(new DiffusionRepositoryDatasource())37->setKey('repositoryPHIDs')38->setAliases(array('repository', 'repositories', 'repositoryPHID'))39->setLabel(pht('Repositories'))40->setDescription(41pht('Search for sync logs for specific repositories.')),42id(new PhabricatorSearchDateField())43->setLabel(pht('Created After'))44->setKey('createdStart'),45id(new PhabricatorSearchDateField())46->setLabel(pht('Created Before'))47->setKey('createdEnd'),48);49}5051protected function newExportFields() {52$viewer = $this->requireViewer();5354$fields = array(55id(new PhabricatorPHIDExportField())56->setKey('repositoryPHID')57->setLabel(pht('Repository PHID')),58id(new PhabricatorStringExportField())59->setKey('repository')60->setLabel(pht('Repository')),61id(new PhabricatorPHIDExportField())62->setKey('devicePHID')63->setLabel(pht('Device PHID')),64id(new PhabricatorPHIDExportField())65->setKey('fromDevicePHID')66->setLabel(pht('From Device PHID')),67id(new PhabricatorIntExportField())68->setKey('deviceVersion')69->setLabel(pht('Device Version')),70id(new PhabricatorIntExportField())71->setKey('fromDeviceVersion')72->setLabel(pht('From Device Version')),73id(new PhabricatorStringExportField())74->setKey('result')75->setLabel(pht('Result')),76id(new PhabricatorIntExportField())77->setKey('code')78->setLabel(pht('Code')),79id(new PhabricatorEpochExportField())80->setKey('date')81->setLabel(pht('Date')),82id(new PhabricatorIntExportField())83->setKey('syncWait')84->setLabel(pht('Sync Wait')),85);8687return $fields;88}8990protected function newExportData(array $events) {91$viewer = $this->requireViewer();9293$export = array();94foreach ($events as $event) {95$repository = $event->getRepository();96$repository_phid = $repository->getPHID();97$repository_name = $repository->getDisplayName();9899$map = array(100'repositoryPHID' => $repository_phid,101'repository' => $repository_name,102'devicePHID' => $event->getDevicePHID(),103'fromDevicePHID' => $event->getFromDevicePHID(),104'deviceVersion' => $event->getDeviceVersion(),105'fromDeviceVersion' => $event->getFromDeviceVersion(),106'result' => $event->getResultType(),107'code' => $event->getResultCode(),108'date' => $event->getEpoch(),109'syncWait' => $event->getSyncWait(),110);111112$export[] = $map;113}114115return $export;116}117118protected function getURI($path) {119return '/diffusion/synclog/'.$path;120}121122protected function getBuiltinQueryNames() {123return array(124'all' => pht('All Sync Logs'),125);126}127128public function buildSavedQueryFromBuiltin($query_key) {129$query = $this->newSavedQuery();130$query->setQueryKey($query_key);131132switch ($query_key) {133case 'all':134return $query;135}136137return parent::buildSavedQueryFromBuiltin($query_key);138}139140protected function renderResultList(141array $logs,142PhabricatorSavedQuery $query,143array $handles) {144145$table = id(new DiffusionSyncLogListView())146->setViewer($this->requireViewer())147->setLogs($logs);148149return id(new PhabricatorApplicationSearchResultView())150->setTable($table);151}152153}154155156