Page MenuHomePhabricator

D7326.id16500.diff
No OneTemporary

D7326.id16500.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -201,6 +201,9 @@
'ConduitAPI_phpast_Method' => 'applications/phpast/conduit/ConduitAPI_phpast_Method.php',
'ConduitAPI_phpast_getast_Method' => 'applications/phpast/conduit/ConduitAPI_phpast_getast_Method.php',
'ConduitAPI_phpast_version_Method' => 'applications/phpast/conduit/ConduitAPI_phpast_version_Method.php',
+ 'ConduitAPI_phrequent_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_Method.php',
+ 'ConduitAPI_phrequent_start_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_start_Method.php',
+ 'ConduitAPI_phrequent_stop_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_stop_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',
@@ -2319,6 +2322,9 @@
'ConduitAPI_phpast_Method' => 'ConduitAPIMethod',
'ConduitAPI_phpast_getast_Method' => 'ConduitAPI_phpast_Method',
'ConduitAPI_phpast_version_Method' => 'ConduitAPI_phpast_Method',
+ 'ConduitAPI_phrequent_Method' => 'ConduitAPIMethod',
+ 'ConduitAPI_phrequent_start_Method' => 'ConduitAPI_phrequent_Method',
+ 'ConduitAPI_phrequent_stop_Method' => 'ConduitAPI_phrequent_Method',
'ConduitAPI_phriction_Method' => 'ConduitAPIMethod',
'ConduitAPI_phriction_edit_Method' => 'ConduitAPI_phriction_Method',
'ConduitAPI_phriction_history_Method' => 'ConduitAPI_phriction_Method',
Index: src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php
===================================================================
--- /dev/null
+++ src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * @group conduit
+ */
+abstract class ConduitAPI_phrequent_Method extends ConduitAPIMethod {
+
+ public function getApplication() {
+ return PhabricatorApplication::getByClass(
+ 'PhabricatorApplicationPhrequent');
+ }
+
+
+}
Index: src/applications/phrequent/conduit/ConduitAPI_phrequent_start_Method.php
===================================================================
--- /dev/null
+++ src/applications/phrequent/conduit/ConduitAPI_phrequent_start_Method.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ *@group conduit
+ */
+final class ConduitAPI_phrequent_start_Method
+ extends ConduitAPI_phrequent_Method {
+
+ public function getMethodDescription() {
+ return "Start tracking time on an object.";
+ }
+
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'object' => 'required phid'
+ );
+ }
+
+ public function defineReturnType() {
+ return 'bool';
+ }
+
+ public function defineErrorTypes() {
+ return array(
+ );
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $user_id = $request->getUser()->getPHID();
+ $object_id = $request->getValue('object');
+
+ $usertime = new PhrequentUserTime();
+ $usertime->setDateStarted(time());
+ $usertime->setUserPHID($user_id);
+ $usertime->setObjectPHID($object_id);
+ $usertime->save();
+
+ return true;
+ }
+
+}
Index: src/applications/phrequent/conduit/ConduitAPI_phrequent_stop_Method.php
===================================================================
--- /dev/null
+++ src/applications/phrequent/conduit/ConduitAPI_phrequent_stop_Method.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ *@group conduit
+ */
+final class ConduitAPI_phrequent_stop_Method
+ extends ConduitAPI_phrequent_Method {
+
+ public function getMethodDescription() {
+ return "Stop tracking time on an object.";
+ }
+
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'object' => 'required phid'
+ );
+ }
+
+ public function defineReturnType() {
+ return 'bool';
+ }
+
+ public function defineErrorTypes() {
+ return array(
+ );
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $user = $request->getUser();
+ $phid = $request->getValue('object');
+
+ if (!PhrequentUserTimeQuery::isUserTrackingObject($user, $phid)) {
+ // Don't do anything, it's not being tracked.
+ return false;
+ }
+
+ $usertime_dao = new PhrequentUserTime();
+ $conn = $usertime_dao->establishConnection('r');
+
+ queryfx(
+ $conn,
+ 'UPDATE %T usertime '.
+ 'SET usertime.dateEnded = UNIX_TIMESTAMP() '.
+ 'WHERE usertime.userPHID = %s '.
+ 'AND usertime.objectPHID = %s '.
+ 'AND usertime.dateEnded IS NULL '.
+ 'ORDER BY usertime.dateStarted, usertime.id DESC '.
+ 'LIMIT 1',
+ $usertime_dao->getTableName(),
+ $user->getPHID(),
+ $phid);
+
+ return true;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 3:02 AM (36 m, 27 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6928280
Default Alt Text
D7326.id16500.diff (5 KB)

Event Timeline