Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15443976
D12381.id29724.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
D12381.id29724.diff
View Options
diff --git a/src/applications/conduit/controller/PhabricatorConduitConsoleController.php b/src/applications/conduit/controller/PhabricatorConduitConsoleController.php
--- a/src/applications/conduit/controller/PhabricatorConduitConsoleController.php
+++ b/src/applications/conduit/controller/PhabricatorConduitConsoleController.php
@@ -119,7 +119,65 @@
$form_box = id(new PHUIObjectBoxView())
->setHeader($header)
->setFormErrors($errors)
- ->setForm($form);
+ ->appendChild($form);
+
+ $content = array();
+
+ $query = $method->newQueryObject();
+ if ($query) {
+ $orders = $query->getBuiltinOrders();
+
+ $rows = array();
+ foreach ($orders as $key => $order) {
+ $rows[] = array(
+ $key,
+ $order['name'],
+ implode(', ', $order['vector']),
+ );
+ }
+
+ $table = id(new AphrontTableView($rows))
+ ->setHeaders(
+ array(
+ pht('Key'),
+ pht('Description'),
+ pht('Columns'),
+ ))
+ ->setColumnClasses(
+ array(
+ 'pri',
+ '',
+ 'wide',
+ ));
+ $content[] = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Builtin Orders'))
+ ->appendChild($table);
+
+ $columns = $query->getOrderableColumns();
+
+ $rows = array();
+ foreach ($columns as $key => $column) {
+ $rows[] = array(
+ $key,
+ idx($column, 'unique') ? pht('Yes') : pht('No'),
+ );
+ }
+
+ $table = id(new AphrontTableView($rows))
+ ->setHeaders(
+ array(
+ pht('Key'),
+ pht('Unique'),
+ ))
+ ->setColumnClasses(
+ array(
+ 'pri',
+ 'wide',
+ ));
+ $content[] = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Column Orders'))
+ ->appendChild($table);
+ }
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($method->getAPIMethodName());
@@ -128,6 +186,7 @@
array(
$crumbs,
$form_box,
+ $content,
),
array(
'title' => $method->getAPIMethodName(),
diff --git a/src/applications/conduit/method/ConduitAPIMethod.php b/src/applications/conduit/method/ConduitAPIMethod.php
--- a/src/applications/conduit/method/ConduitAPIMethod.php
+++ b/src/applications/conduit/method/ConduitAPIMethod.php
@@ -26,7 +26,15 @@
public function __construct() {}
public function getParamTypes() {
- return $this->defineParamTypes();
+ $types = $this->defineParamTypes();
+
+ $query = $this->newQueryObject();
+ if ($query) {
+ $types['order'] = 'order';
+ $types += $this->getPagerParamTypes();
+ }
+
+ return $types;
}
public function getReturnType() {
@@ -253,6 +261,48 @@
}
+/* -( Implementing Query Methods )----------------------------------------- */
+
+
+ public function newQueryObject() {
+ return null;
+ }
+
+
+ protected function newQueryForRequest(ConduitAPIRequest $request) {
+ $query = $this->newQueryObject();
+
+ if (!$query) {
+ throw new Exception(
+ pht(
+ 'You can not call newQueryFromRequest() in this method ("%s") '.
+ 'because it does not implement newQueryObject().',
+ get_class($this)));
+ }
+
+ if (!($query instanceof PhabricatorCursorPagedPolicyAwareQuery)) {
+ throw new Exception(
+ pht(
+ 'Call to method newQueryObject() did not return an object of class '.
+ '"%s".',
+ 'PhabricatorCursorPagedPolicyAwareQuery'));
+ }
+
+ $query->setViewer($request->getUser());
+
+ $order = $request->getValue('order');
+ if ($order !== null) {
+ if (is_scalar($order)) {
+ $query->setOrder($order);
+ } else {
+ $query->setOrderVector($order);
+ }
+ }
+
+ return $query;
+ }
+
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php b/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php
--- a/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php
+++ b/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php
@@ -19,6 +19,10 @@
return pht('Query repositories.');
}
+ public function newQueryObject() {
+ return new PhabricatorRepositoryQuery();
+ }
+
protected function defineParamTypes() {
return array(
'ids' => 'optional list<int>',
@@ -35,8 +39,7 @@
}
protected function execute(ConduitAPIRequest $request) {
- $query = id(new PhabricatorRepositoryQuery())
- ->setViewer($request->getUser());
+ $query = $this->newQueryForRequest($request);
$ids = $request->getValue('ids', array());
if ($ids) {
@@ -68,7 +71,8 @@
$query->withUUIDs($uuids);
}
- $repositories = $query->execute();
+ $pager = $this->newPager($request);
+ $repositories = $query->executeWithCursorPager($pager);
$results = array();
foreach ($repositories as $repository) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 28, 7:10 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7724725
Default Alt Text
D12381.id29724.diff (5 KB)
Attached To
Mode
D12381: Drive conduit result ordering through Query order specifications
Attached
Detach File
Event Timeline
Log In to Comment