@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhrequentTrackingConduitAPIMethod
4 extends PhrequentConduitAPIMethod {
5
6 public function getAPIMethodName() {
7 return 'phrequent.tracking';
8 }
9
10 public function getMethodDescription() {
11 return pht('Returns current objects being tracked in Phrequent.');
12 }
13
14 protected function defineParamTypes() {
15 return array();
16 }
17
18 protected function defineReturnType() {
19 return 'array';
20 }
21
22 protected function execute(ConduitAPIRequest $request) {
23 $user = $request->getUser();
24
25 $times = id(new PhrequentUserTimeQuery())
26 ->setViewer($user)
27 ->needPreemptingEvents(true)
28 ->withEnded(PhrequentUserTimeQuery::ENDED_NO)
29 ->withUserPHIDs(array($user->getPHID()))
30 ->execute();
31
32 $now = time();
33
34 $results = id(new PhrequentTimeBlock($times))
35 ->getCurrentWorkStack($now);
36
37 return array('data' => $results);
38 }
39
40}