Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14398231
D17156.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D17156.diff
View Options
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
@@ -2025,6 +2025,7 @@
'PhabricatorBcryptPasswordHasher' => 'infrastructure/util/password/PhabricatorBcryptPasswordHasher.php',
'PhabricatorBinariesSetupCheck' => 'applications/config/check/PhabricatorBinariesSetupCheck.php',
'PhabricatorBitbucketAuthProvider' => 'applications/auth/provider/PhabricatorBitbucketAuthProvider.php',
+ 'PhabricatorBoardColumnsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php',
'PhabricatorBoardLayoutEngine' => 'applications/project/engine/PhabricatorBoardLayoutEngine.php',
'PhabricatorBoardRenderingEngine' => 'applications/project/engine/PhabricatorBoardRenderingEngine.php',
'PhabricatorBoardResponseEngine' => 'applications/project/engine/PhabricatorBoardResponseEngine.php',
@@ -6926,6 +6927,7 @@
'PhabricatorBcryptPasswordHasher' => 'PhabricatorPasswordHasher',
'PhabricatorBinariesSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorBitbucketAuthProvider' => 'PhabricatorOAuth1AuthProvider',
+ 'PhabricatorBoardColumnsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
'PhabricatorBoardLayoutEngine' => 'Phobject',
'PhabricatorBoardRenderingEngine' => 'Phobject',
'PhabricatorBoardResponseEngine' => 'Phobject',
diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php
--- a/src/applications/maniphest/storage/ManiphestTask.php
+++ b/src/applications/maniphest/storage/ManiphestTask.php
@@ -505,7 +505,10 @@
}
public function getConduitSearchAttachments() {
- return array();
+ return array(
+ id(new PhabricatorBoardColumnsSearchEngineAttachment())
+ ->setAttachmentKey('columns'),
+ );
}
diff --git a/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php b/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php
@@ -0,0 +1,80 @@
+<?php
+
+final class PhabricatorBoardColumnsSearchEngineAttachment
+ extends PhabricatorSearchEngineAttachment {
+
+ public function getAttachmentName() {
+ return pht('Workboard Columns');
+ }
+
+ public function getAttachmentDescription() {
+ return pht('Get the workboard columns where an object appears.');
+ }
+
+ public function loadAttachmentData(array $objects, $spec) {
+ $viewer = $this->getViewer();
+
+ $objects = mpull($objects, null, 'getPHID');
+ $object_phids = array_keys($objects);
+
+ $edge_query = id(new PhabricatorEdgeQuery())
+ ->withSourcePHIDs($object_phids)
+ ->withEdgeTypes(
+ array(
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
+ ));
+ $edge_query->execute();
+
+ $project_phids = $edge_query->getDestinationPHIDs();
+
+ $engine = id(new PhabricatorBoardLayoutEngine())
+ ->setViewer($viewer)
+ ->setBoardPHIDs($project_phids)
+ ->setObjectPHIDs($object_phids)
+ ->executeLayout();
+
+ $results = array();
+ foreach ($objects as $phid => $object) {
+ $board_phids = $edge_query->getDestinationPHIDs(array($phid));
+
+ $boards = array();
+ foreach ($board_phids as $board_phid) {
+ $columns = array();
+ foreach ($engine->getObjectColumns($board_phid, $phid) as $column) {
+ if ($column->getProxyPHID()) {
+ // When an object is in a proxy column, don't return it on this
+ // attachment. This information can be reconstructed from other
+ // queries, is something of an implementation detail, and seems
+ // unlikely to be interesting to API consumers.
+ continue 2;
+ }
+
+ $columns[] = $column->getRefForConduit();
+ }
+
+ // If a project has no workboard, the object won't appear on any
+ // columns. Just omit it from the result set.
+ if (!$columns) {
+ continue;
+ }
+
+ $boards[$board_phid] = array(
+ 'columns' => $columns,
+ );
+ }
+
+ $results[$phid] = $boards;
+ }
+
+ return $results;
+ }
+
+ public function getAttachmentForObject($object, $data, $spec) {
+ $boards = idx($data, $object->getPHID(), array());
+
+ return array(
+ 'boards' => $boards,
+ );
+ }
+
+}
diff --git a/src/applications/project/storage/PhabricatorProjectColumn.php b/src/applications/project/storage/PhabricatorProjectColumn.php
--- a/src/applications/project/storage/PhabricatorProjectColumn.php
+++ b/src/applications/project/storage/PhabricatorProjectColumn.php
@@ -183,6 +183,14 @@
return sprintf('%s%012d', $group, $sequence);
}
+ public function getRefForConduit() {
+ return array(
+ 'id' => (int)$this->getID(),
+ 'phid' => $this->getPHID(),
+ 'name' => $this->getDisplayName(),
+ );
+ }
+
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 1:19 PM (18 h, 1 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921306
Default Alt Text
D17156.diff (5 KB)
Attached To
Mode
D17156: Add a "columns" attachment to the maniphest.search API method
Attached
Detach File
Event Timeline
Log In to Comment