mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-07 12:28:28 +01:00
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
This commit is contained in:
parent
fc814647e6
commit
0292793d4d
2 changed files with 31 additions and 12 deletions
|
@ -29,7 +29,8 @@ final class PhrequentSearchEngine extends PhabricatorApplicationSearchEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
||||||
$query = id(new PhrequentUserTimeQuery());
|
$query = id(new PhrequentUserTimeQuery())
|
||||||
|
->needPreemptingEvents(true);
|
||||||
|
|
||||||
$user_phids = $saved->getParameter('userPHIDs');
|
$user_phids = $saved->getParameter('userPHIDs');
|
||||||
if ($user_phids) {
|
if ($user_phids) {
|
||||||
|
@ -136,7 +137,6 @@ final class PhrequentSearchEngine extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
foreach ($usertimes as $usertime) {
|
foreach ($usertimes as $usertime) {
|
||||||
$item = new PHUIObjectItemView();
|
$item = new PHUIObjectItemView();
|
||||||
|
|
||||||
if ($usertime->getObjectPHID() === null) {
|
if ($usertime->getObjectPHID() === null) {
|
||||||
$item->setHeader($usertime->getNote());
|
$item->setHeader($usertime->getNote());
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,12 +154,10 @@ final class PhrequentSearchEngine extends PhabricatorApplicationSearchEngine {
|
||||||
$started_date = phabricator_date($usertime->getDateStarted(), $viewer);
|
$started_date = phabricator_date($usertime->getDateStarted(), $viewer);
|
||||||
$item->addIcon('none', $started_date);
|
$item->addIcon('none', $started_date);
|
||||||
|
|
||||||
if ($usertime->getDateEnded() !== null) {
|
$block = new PhrequentTimeBlock(array($usertime));
|
||||||
$time_spent = $usertime->getDateEnded() - $usertime->getDateStarted();
|
$time_spent = $block->getTimeSpentOnObject(
|
||||||
$time_ended = phabricator_datetime($usertime->getDateEnded(), $viewer);
|
$usertime->getObjectPHID(),
|
||||||
} else {
|
PhabricatorTime::getNow());
|
||||||
$time_spent = time() - $usertime->getDateStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
$time_spent = $time_spent == 0 ? 'none' :
|
$time_spent = $time_spent == 0 ? 'none' :
|
||||||
phutil_format_relative_time_detailed($time_spent);
|
phutil_format_relative_time_detailed($time_spent);
|
||||||
|
@ -172,7 +170,7 @@ final class PhrequentSearchEngine extends PhabricatorApplicationSearchEngine {
|
||||||
$item->addAttribute(
|
$item->addAttribute(
|
||||||
pht(
|
pht(
|
||||||
'Ended on %s',
|
'Ended on %s',
|
||||||
$time_ended));
|
phabricator_datetime($usertime->getDateEnded(), $viewer)));
|
||||||
} else {
|
} else {
|
||||||
$item->addAttribute(
|
$item->addAttribute(
|
||||||
pht(
|
pht(
|
||||||
|
|
|
@ -199,10 +199,31 @@ final class PhrequentUserTimeQuery
|
||||||
$u_start = $u_event->getDateStarted();
|
$u_start = $u_event->getDateStarted();
|
||||||
$u_end = $u_event->getDateEnded();
|
$u_end = $u_event->getDateEnded();
|
||||||
|
|
||||||
if (($u_start >= $e_start) &&
|
if ($u_start < $e_start) {
|
||||||
($u_end === null || $u_end > $e_start)) {
|
// This event started before our event started, so it's not
|
||||||
$select[] = $u_event;
|
// preempting us.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($u_start == $e_start) {
|
||||||
|
if ($u_event->getID() < $event->getID()) {
|
||||||
|
// This event started at the same time as our event started,
|
||||||
|
// but has a lower ID, so it's not preempting us.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($e_end !== null) && ($u_start > $e_end)) {
|
||||||
|
// Our event has ended, and this event started after it ended.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($u_end !== null) && ($u_end < $e_start)) {
|
||||||
|
// This event ended before our event began.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$select[] = $u_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->attachPreemptingEvents($select);
|
$event->attachPreemptingEvents($select);
|
||||||
|
|
Loading…
Add table
Reference in a new issue