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

Fix Phrequent duration accounting

Summary: Fixes T5705. This was just derp; instead of returning the duration of the first slice, return the duration of all the slices.

Test Plan: Added unit tests. Saw reasonable results in the UI.

Reviewers: btrahan, hach-que

Reviewed By: hach-que

Subscribers: epriestley

Maniphest Tasks: T5705

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

+28 -2
+4 -2
src/applications/phrequent/storage/PhrequentTimeSlices.php
··· 17 17 } 18 18 19 19 public function getDuration($now) { 20 + $total = 0; 20 21 foreach ($this->ranges as $range) { 21 22 if ($range[1] === null) { 22 - return $now - $range[0]; 23 + $total += $now - $range[0]; 23 24 } else { 24 - return $range[1] - $range[0]; 25 + $total += $range[1] - $range[0]; 25 26 } 26 27 } 28 + return $total; 27 29 } 28 30 29 31 public function getIsOngoing() {
+24
src/applications/phrequent/storage/__tests__/PhrequentTimeBlockTestCase.php
··· 282 282 $ranges); 283 283 } 284 284 285 + public function testSumTimeSlices() { 286 + // This block has multiple closed slices. 287 + $block = new PhrequentTimeBlock( 288 + array( 289 + $this->newEvent('T1', 3456, 4456)->attachPreemptingEvents(array()), 290 + $this->newEvent('T1', 8000, 9000)->attachPreemptingEvents(array()), 291 + )); 292 + 293 + $this->assertEqual( 294 + 2000, 295 + $block->getTimeSpentOnObject('T1', 10000)); 296 + 297 + // This block has an open slice. 298 + $block = new PhrequentTimeBlock( 299 + array( 300 + $this->newEvent('T1', 3456, 4456)->attachPreemptingEvents(array()), 301 + $this->newEvent('T1', 8000, null)->attachPreemptingEvents(array()), 302 + )); 303 + 304 + $this->assertEqual( 305 + 3000, 306 + $block->getTimeSpentOnObject('T1', 10000)); 307 + } 308 + 285 309 private function newEvent($object_phid, $start_time, $end_time) { 286 310 static $id = 0; 287 311