Page MenuHomePhabricator

D9272.diff
No OneTemporary

D9272.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
@@ -225,6 +225,8 @@
'ConduitAPI_phragment_Method' => 'applications/phragment/conduit/ConduitAPI_phragment_Method.php',
'ConduitAPI_phragment_getpatch_Method' => 'applications/phragment/conduit/ConduitAPI_phragment_getpatch_Method.php',
'ConduitAPI_phragment_queryfragments_Method' => 'applications/phragment/conduit/ConduitAPI_phragment_queryfragments_Method.php',
+ 'ConduitAPI_phrequent_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_Method.php',
+ 'ConduitAPI_phrequent_query_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php',
'ConduitAPI_phriction_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_Method.php',
'ConduitAPI_phriction_edit_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_edit_Method.php',
'ConduitAPI_phriction_history_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_history_Method.php',
@@ -2898,6 +2900,8 @@
'ConduitAPI_phragment_Method' => 'ConduitAPIMethod',
'ConduitAPI_phragment_getpatch_Method' => 'ConduitAPI_phragment_Method',
'ConduitAPI_phragment_queryfragments_Method' => 'ConduitAPI_phragment_Method',
+ 'ConduitAPI_phrequent_Method' => 'ConduitAPIMethod',
+ 'ConduitAPI_phrequent_query_Method' => 'ConduitAPI_phrequent_Method',
'ConduitAPI_phriction_Method' => 'ConduitAPIMethod',
'ConduitAPI_phriction_edit_Method' => 'ConduitAPI_phriction_Method',
'ConduitAPI_phriction_history_Method' => 'ConduitAPI_phriction_Method',
diff --git a/src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php b/src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * @group conduit
+ */
+
+abstract class ConduitAPI_phrequent_Method extends ConduitAPIMethod {
+
+ public function getApplication() {
+ return
+ PhabricatorApplication::getByClass('PhabricatorApplicationPhrequent');
+ }
+
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
+ public function getMethodStatusDescription() {
+ return pht('Phrequent is still in beta.
+ The Conduit API was recently added and still under development.');
+ }
+
+ protected function buildBlockDictionary(array $blocks) {
+ $result = array();
+
+ assert_instances_of($blocks, 'PhrequentUserTime');
+
+ if (!$blocks) {
+ return array();
+ }
+
+ foreach ($blocks as $block) {
+ $result[$block->getID()] = array(
+ 'id' => $block->getID(),
+ 'userPHID' => $block->getUserPHID(),
+ 'objectPHID' => $block->getObjectPHID(),
+ 'note' => $block->getNote(),
+ 'dateStarted' => $block->getDateStarted(),
+ 'dateEnded' => $block->getDateEnded(),
+ 'dateCreated' => $block->getDateCreated(),
+ 'dateModified' => $block->getDateModified());
+ }
+
+ return $result;
+ }
+}
diff --git a/src/applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php b/src/applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * @group conduit
+ */
+
+final class ConduitAPI_phrequent_query_Method
+ extends ConduitAPI_phrequent_Method {
+
+ public function getMethodDescription() {
+ return pht('Run searches for Phrequent time trackers.');
+ }
+
+ public function defineParamTypes() {
+ $ended_options = $this->formatStringConstants(
+ PhrequentUserTimeQuery::getEndedSearchOptions());
+ $order_options = $this->formatStringConstants(
+ PhrequentUserTimeQuery::getOrderSearchOptions());
+
+ return array(
+ 'userPHIDs' => 'optional list<phid>',
+ 'objectPHIDs' => 'optional list<phid>',
+ 'ended' => 'optional '.$ended_options,
+ 'order' => 'optional '.$order_options);
+ }
+
+ public function defineReturnType() {
+ return 'list';
+ }
+
+ public function defineErrorTypes() {
+ return array();
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $query = new PhrequentUserTimeQuery();
+ $query->setViewer($request->getUser());
+
+ $users = $request->getValue('userPHIDs');
+ $objects = $request->getValue('objectPHIDs');
+
+ $ended_options = $query->getEndedSearchOptions();
+ $ended = array_search($request->getValue('ended'), $ended_options);
+
+ $order_options = $query->getorderSearchOptions();
+ $order = array_search($request->getValue('order'), $order_options);
+
+ if ($users) {
+ $query->withUserPHIDs($users);
+ }
+
+ if ($objects) {
+ $query->withObjectPHIDs($objects);
+ }
+
+ if ($ended) {
+ $query->withEnded($ended);
+ }
+
+ if ($order) {
+ $query->setOrder($order);
+ }
+
+ $result = $query->execute();
+
+ return $this->buildBlockDictionary($result);
+ }
+}

File Metadata

Mime Type
text/plain
Expires
May 13 2024, 9:26 PM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6277339
Default Alt Text
D9272.diff (5 KB)

Event Timeline