Page MenuHomePhabricator

D19151.id.diff
No OneTemporary

D19151.id.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1235,6 +1235,8 @@
'HarbormasterBuildLogPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php',
'HarbormasterBuildLogQuery' => 'applications/harbormaster/query/HarbormasterBuildLogQuery.php',
'HarbormasterBuildLogRenderController' => 'applications/harbormaster/controller/HarbormasterBuildLogRenderController.php',
+ 'HarbormasterBuildLogSearchConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterBuildLogSearchConduitAPIMethod.php',
+ 'HarbormasterBuildLogSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildLogSearchEngine.php',
'HarbormasterBuildLogTestCase' => 'applications/harbormaster/__tests__/HarbormasterBuildLogTestCase.php',
'HarbormasterBuildLogView' => 'applications/harbormaster/view/HarbormasterBuildLogView.php',
'HarbormasterBuildLogViewController' => 'applications/harbormaster/controller/HarbormasterBuildLogViewController.php',
@@ -6522,6 +6524,7 @@
'HarbormasterDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorConduitResultInterface',
),
'HarbormasterBuildLogChunk' => 'HarbormasterDAO',
'HarbormasterBuildLogChunkIterator' => 'PhutilBufferedIterator',
@@ -6529,6 +6532,8 @@
'HarbormasterBuildLogPHIDType' => 'PhabricatorPHIDType',
'HarbormasterBuildLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildLogRenderController' => 'HarbormasterController',
+ 'HarbormasterBuildLogSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
+ 'HarbormasterBuildLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HarbormasterBuildLogTestCase' => 'PhabricatorTestCase',
'HarbormasterBuildLogView' => 'AphrontView',
'HarbormasterBuildLogViewController' => 'HarbormasterController',
diff --git a/src/applications/harbormaster/conduit/HarbormasterBuildLogSearchConduitAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterBuildLogSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/conduit/HarbormasterBuildLogSearchConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class HarbormasterBuildLogSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'harbormaster.log.search';
+ }
+
+ public function newSearchEngine() {
+ return new HarbormasterBuildLogSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Find out information about build logs.');
+ }
+
+}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildLogQuery.php b/src/applications/harbormaster/query/HarbormasterBuildLogQuery.php
--- a/src/applications/harbormaster/query/HarbormasterBuildLogQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildLogQuery.php
@@ -23,19 +23,12 @@
return $this;
}
+ public function newResultObject() {
+ return new HarbormasterBuildLog();
+ }
+
protected function loadPage() {
- $table = new HarbormasterBuildLog();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $page) {
@@ -63,33 +56,31 @@
return $page;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->buildTargetPHIDs) {
+ if ($this->buildTargetPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'buildTargetPHID IN (%Ls)',
$this->buildTargetPHIDs);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/harbormaster/query/HarbormasterBuildLogSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildLogSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/query/HarbormasterBuildLogSearchEngine.php
@@ -0,0 +1,79 @@
+<?php
+
+final class HarbormasterBuildLogSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function getResultTypeDescription() {
+ return pht('Harbormaster Build Logs');
+ }
+
+ public function getApplicationClassName() {
+ return 'PhabricatorHarbormasterApplication';
+ }
+
+ public function newQuery() {
+ return new HarbormasterBuildLogQuery();
+ }
+
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Build Targets'))
+ ->setKey('buildTargetPHIDs')
+ ->setAliases(
+ array(
+ 'buildTargetPHID',
+ 'buildTargets',
+ 'buildTarget',
+ 'targetPHIDs',
+ 'targetPHID',
+ 'targets',
+ 'target',
+ ))
+ ->setDescription(
+ pht('Search for logs that belong to a particular build target.')),
+ );
+ }
+
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
+
+ if ($map['buildTargetPHIDs']) {
+ $query->withBuildTargetPHIDs($map['buildTargetPHIDs']);
+ }
+
+ return $query;
+ }
+
+ protected function getURI($path) {
+ return '/harbormaster/log/'.$path;
+ }
+
+ protected function getBuiltinQueryNames() {
+ return array(
+ 'all' => pht('All Builds'),
+ );
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ switch ($query_key) {
+ case 'all':
+ return $query;
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+
+ protected function renderResultList(
+ array $builds,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+
+ // For now, this SearchEngine is only for driving the API.
+ throw new PhutilMethodNotImplementedException();
+ }
+
+}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
@@ -4,7 +4,8 @@
extends HarbormasterDAO
implements
PhabricatorPolicyInterface,
- PhabricatorDestructibleInterface {
+ PhabricatorDestructibleInterface,
+ PhabricatorConduitResultInterface {
protected $buildTargetPHID;
protected $logSource;
@@ -714,4 +715,36 @@
}
+/* -( PhabricatorConduitResultInterface )---------------------------------- */
+
+
+ public function getFieldSpecificationsForConduit() {
+ return array(
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('buildTargetPHID')
+ ->setType('phid')
+ ->setDescription(pht('Build target this log is attached to.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('byteLength')
+ ->setType('int')
+ ->setDescription(pht('Length of the log in bytes.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('filePHID')
+ ->setType('phid?')
+ ->setDescription(pht('A file containing the log data.')),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ return array(
+ 'buildTargetPHID' => $this->getBuildTargetPHID(),
+ 'byteLength' => (int)$this->getByteLength(),
+ 'filePHID' => $this->getFilePHID(),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array();
+ }
+
}
diff --git a/src/view/control/AphrontTableView.php b/src/view/control/AphrontTableView.php
--- a/src/view/control/AphrontTableView.php
+++ b/src/view/control/AphrontTableView.php
@@ -248,7 +248,7 @@
foreach ($col_classes as $key => $value) {
- if (($sort_values[$key] !== null) &&
+ if (isset($sort_values[$key]) &&
($sort_values[$key] == $this->sortSelected)) {
$value = trim($value.' sorted-column');
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 7:41 PM (1 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7394739
Default Alt Text
D19151.id.diff (8 KB)

Event Timeline