@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Account for preempting events on the Phrequent list view

Summary: Fixes T5850. Also fixes some logic where the wrong preempting events could be attached during a bulk query.

Test Plan: Phrequent list now shows preemption-aware times.

Reviewers: hach-que, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5850

Differential Revision: https://secure.phabricator.com/D10223

+31 -12
+7 -9
src/applications/phrequent/query/PhrequentSearchEngine.php
··· 29 29 } 30 30 31 31 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 32 - $query = id(new PhrequentUserTimeQuery()); 32 + $query = id(new PhrequentUserTimeQuery()) 33 + ->needPreemptingEvents(true); 33 34 34 35 $user_phids = $saved->getParameter('userPHIDs'); 35 36 if ($user_phids) { ··· 136 137 137 138 foreach ($usertimes as $usertime) { 138 139 $item = new PHUIObjectItemView(); 139 - 140 140 if ($usertime->getObjectPHID() === null) { 141 141 $item->setHeader($usertime->getNote()); 142 142 } else { ··· 154 154 $started_date = phabricator_date($usertime->getDateStarted(), $viewer); 155 155 $item->addIcon('none', $started_date); 156 156 157 - if ($usertime->getDateEnded() !== null) { 158 - $time_spent = $usertime->getDateEnded() - $usertime->getDateStarted(); 159 - $time_ended = phabricator_datetime($usertime->getDateEnded(), $viewer); 160 - } else { 161 - $time_spent = time() - $usertime->getDateStarted(); 162 - } 157 + $block = new PhrequentTimeBlock(array($usertime)); 158 + $time_spent = $block->getTimeSpentOnObject( 159 + $usertime->getObjectPHID(), 160 + PhabricatorTime::getNow()); 163 161 164 162 $time_spent = $time_spent == 0 ? 'none' : 165 163 phutil_format_relative_time_detailed($time_spent); ··· 172 170 $item->addAttribute( 173 171 pht( 174 172 'Ended on %s', 175 - $time_ended)); 173 + phabricator_datetime($usertime->getDateEnded(), $viewer))); 176 174 } else { 177 175 $item->addAttribute( 178 176 pht(
+24 -3
src/applications/phrequent/query/PhrequentUserTimeQuery.php
··· 199 199 $u_start = $u_event->getDateStarted(); 200 200 $u_end = $u_event->getDateEnded(); 201 201 202 - if (($u_start >= $e_start) && 203 - ($u_end === null || $u_end > $e_start)) { 204 - $select[] = $u_event; 202 + if ($u_start < $e_start) { 203 + // This event started before our event started, so it's not 204 + // preempting us. 205 + continue; 206 + } 207 + 208 + if ($u_start == $e_start) { 209 + if ($u_event->getID() < $event->getID()) { 210 + // This event started at the same time as our event started, 211 + // but has a lower ID, so it's not preempting us. 212 + continue; 213 + } 214 + } 215 + 216 + if (($e_end !== null) && ($u_start > $e_end)) { 217 + // Our event has ended, and this event started after it ended. 218 + continue; 219 + } 220 + 221 + if (($u_end !== null) && ($u_end < $e_start)) { 222 + // This event ended before our event began. 223 + continue; 205 224 } 225 + 226 + $select[] = $u_event; 206 227 } 207 228 208 229 $event->attachPreemptingEvents($select);