1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Add support for querying feed transactions by author and date range

Summary: Depends on D20531. Ref T13294. Enable finding raw transactions in particular date ranges or with particular authors.

Test Plan: {F6463471}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13294

Differential Revision: https://secure.phabricator.com/D20533
This commit is contained in:
epriestley 2019-05-21 05:23:31 -07:00
parent 642113708a
commit 2e5b1885e7
2 changed files with 45 additions and 2 deletions

View file

@ -4,6 +4,7 @@ final class PhabricatorFeedTransactionQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $phids;
private $authorPHIDs;
private $createdMin;
private $createdMax;
@ -12,6 +13,11 @@ final class PhabricatorFeedTransactionQuery
return $this;
}
public function withAuthorPHIDs(array $phids) {
$this->authorPHIDs = $phids;
return $this;
}
public function withDateCreatedBetween($min, $max) {
$this->createdMin = $min;
$this->createdMax = $max;
@ -59,6 +65,7 @@ final class PhabricatorFeedTransactionQuery
$created_max = $this->createdMax;
$xaction_phids = $this->phids;
$author_phids = $this->authorPHIDs;
foreach ($queries as $query) {
$query->withDateCreatedBetween($created_min, $created_max);
@ -67,6 +74,10 @@ final class PhabricatorFeedTransactionQuery
$query->withPHIDs($xaction_phids);
}
if ($author_phids !== null) {
$query->withAuthorPHIDs($author_phids);
}
if ($limit !== null) {
$query->setLimit($limit);
}

View file

@ -16,12 +16,44 @@ final class PhabricatorFeedTransactionSearchEngine
}
protected function buildCustomSearchFields() {
return array();
return array(
id(new PhabricatorUsersSearchField())
->setLabel(pht('Authors'))
->setKey('authorPHIDs')
->setAliases(array('author', 'authors')),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created After'))
->setKey('createdStart'),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created Before'))
->setKey('createdEnd'),
);
}
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
if ($map['authorPHIDs']) {
$query->withAuthorPHIDs($map['authorPHIDs']);
}
$created_min = $map['createdStart'];
$created_max = $map['createdEnd'];
if ($created_min && $created_max) {
if ($created_min > $created_max) {
throw new PhabricatorSearchConstraintException(
pht(
'The specified "Created Before" date is earlier in time than the '.
'specified "Created After" date, so this query can never match '.
'any results.'));
}
}
if ($created_min || $created_max) {
$query->withDateCreatedBetween($created_min, $created_max);
}
return $query;
}
@ -93,7 +125,7 @@ final class PhabricatorFeedTransactionSearchEngine
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Actor'),
pht('Author'),
pht('Object'),
pht('Transaction'),
pht('Date'),