mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 21:32:43 +01:00
Show only recent open revisions affecting the same files
Summary: Fixes T5658. Over a long period of time, some cruft can build up here. Only show revisions which have been updated in the last 30 days. Test Plan: - Viewed panel in Differential and Diffusion. - Changed limit from 30 days to 30 seconds and saw no revisions. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5658 Differential Revision: https://secure.phabricator.com/D12158
This commit is contained in:
parent
6ce4044bfa
commit
e5445de163
4 changed files with 47 additions and 5 deletions
|
@ -780,9 +780,12 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
return array();
|
||||
}
|
||||
|
||||
$recent = (PhabricatorTime::getNow() - phutil_units('30 days in seconds'));
|
||||
|
||||
$query = id(new DifferentialRevisionQuery())
|
||||
->setViewer($this->getRequest()->getUser())
|
||||
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
|
||||
->withUpdatedEpochBetween($recent, null)
|
||||
->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED)
|
||||
->setLimit(10)
|
||||
->needFlags(true)
|
||||
|
@ -807,13 +810,17 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
|
||||
private function renderOtherRevisions(array $revisions) {
|
||||
assert_instances_of($revisions, 'DifferentialRevision');
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$user = $this->getRequest()->getUser();
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Similar Open Revisions'))
|
||||
->setSubheader(
|
||||
pht('Recently updated open revisions affecting the same files.'));
|
||||
|
||||
$view = id(new DifferentialRevisionListView())
|
||||
->setHeader(pht('Open Revisions Affecting These Files'))
|
||||
->setHeader($header)
|
||||
->setRevisions($revisions)
|
||||
->setUser($user);
|
||||
->setUser($viewer);
|
||||
|
||||
$phids = $view->getRequiredHandlePHIDs();
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
|
|
@ -38,6 +38,8 @@ final class DifferentialRevisionQuery
|
|||
private $branches = array();
|
||||
private $arcanistProjectPHIDs = array();
|
||||
private $repositoryPHIDs;
|
||||
private $updatedEpochMin;
|
||||
private $updatedEpochMax;
|
||||
|
||||
private $order = 'order-modified';
|
||||
const ORDER_MODIFIED = 'order-modified';
|
||||
|
@ -253,6 +255,12 @@ final class DifferentialRevisionQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withUpdatedEpochBetween($min, $max) {
|
||||
$this->updatedEpochMin = $min;
|
||||
$this->updatedEpochMax = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set result ordering. Provide a class constant, such as
|
||||
|
@ -764,6 +772,20 @@ final class DifferentialRevisionQuery
|
|||
$this->arcanistProjectPHIDs);
|
||||
}
|
||||
|
||||
if ($this->updatedEpochMin !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'r.dateModified >= %d',
|
||||
$this->updatedEpochMin);
|
||||
}
|
||||
|
||||
if ($this->updatedEpochMax !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'r.dateModified <= %d',
|
||||
$this->updatedEpochMax);
|
||||
}
|
||||
|
||||
switch ($this->status) {
|
||||
case self::STATUS_ANY:
|
||||
break;
|
||||
|
|
|
@ -191,8 +191,13 @@ final class DifferentialRevisionListView extends AphrontView {
|
|||
if ($this->header && !$this->noBox) {
|
||||
$list->setFlush(true);
|
||||
$list = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($this->header)
|
||||
->appendChild($list);
|
||||
|
||||
if ($this->header instanceof PHUIHeaderView) {
|
||||
$list->setHeader($this->header);
|
||||
} else {
|
||||
$list->setHeaderText($this->header);
|
||||
}
|
||||
} else {
|
||||
$list->setHeader($this->header);
|
||||
}
|
||||
|
|
|
@ -192,10 +192,13 @@ abstract class DiffusionBrowseController extends DiffusionController {
|
|||
return null;
|
||||
}
|
||||
|
||||
$recent = (PhabricatorTime::getNow() - phutil_units('30 days in seconds'));
|
||||
|
||||
$revisions = id(new DifferentialRevisionQuery())
|
||||
->setViewer($user)
|
||||
->withPath($repository->getID(), $path_id)
|
||||
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
|
||||
->withUpdatedEpochBetween($recent, null)
|
||||
->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED)
|
||||
->setLimit(10)
|
||||
->needRelationships(true)
|
||||
|
@ -207,8 +210,13 @@ abstract class DiffusionBrowseController extends DiffusionController {
|
|||
return null;
|
||||
}
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Open Revisions'))
|
||||
->setSubheader(
|
||||
pht('Recently updated open revisions affecting this file.'));
|
||||
|
||||
$view = id(new DifferentialRevisionListView())
|
||||
->setHeader(pht('Pending Differential Revisions'))
|
||||
->setHeader($header)
|
||||
->setRevisions($revisions)
|
||||
->setUser($user);
|
||||
|
||||
|
|
Loading…
Reference in a new issue