mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Allow users to seach for projects by watcher
Summary: Ref T10349. This capability didn't make a ton of sense when you had to be a member to watch a project and watch rules were simple, but makes more sense now. A particular use case might be finding all the stuff you're watching so you can prune it. Test Plan: Searched for stuff I was watching, got accurate results. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10349 Differential Revision: https://secure.phabricator.com/D15289
This commit is contained in:
parent
8c3ca2a729
commit
9a16e5c1aa
2 changed files with 30 additions and 1 deletions
|
@ -6,6 +6,7 @@ final class PhabricatorProjectQuery
|
|||
private $ids;
|
||||
private $phids;
|
||||
private $memberPHIDs;
|
||||
private $watcherPHIDs;
|
||||
private $slugs;
|
||||
private $slugNormals;
|
||||
private $slugMap;
|
||||
|
@ -62,6 +63,11 @@ final class PhabricatorProjectQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withWatcherPHIDs(array $watcher_phids) {
|
||||
$this->watcherPHIDs = $watcher_phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withSlugs(array $slugs) {
|
||||
$this->slugs = $slugs;
|
||||
return $this;
|
||||
|
@ -436,6 +442,13 @@ final class PhabricatorProjectQuery
|
|||
$this->memberPHIDs);
|
||||
}
|
||||
|
||||
if ($this->watcherPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'w.dst IN (%Ls)',
|
||||
$this->watcherPHIDs);
|
||||
}
|
||||
|
||||
if ($this->slugs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
|
@ -549,7 +562,7 @@ final class PhabricatorProjectQuery
|
|||
}
|
||||
|
||||
protected function shouldGroupQueryResultRows() {
|
||||
if ($this->memberPHIDs || $this->nameTokens) {
|
||||
if ($this->memberPHIDs || $this->watcherPHIDs || $this->nameTokens) {
|
||||
return true;
|
||||
}
|
||||
return parent::shouldGroupQueryResultRows();
|
||||
|
@ -566,6 +579,14 @@ final class PhabricatorProjectQuery
|
|||
PhabricatorProjectMaterializedMemberEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
if ($this->watcherPHIDs !== null) {
|
||||
$joins[] = qsprintf(
|
||||
$conn,
|
||||
'JOIN %T w ON w.src = p.phid AND w.type = %d',
|
||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
|
||||
PhabricatorObjectHasWatcherEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
if ($this->slugs !== null) {
|
||||
$joins[] = qsprintf(
|
||||
$conn,
|
||||
|
|
|
@ -26,6 +26,10 @@ final class PhabricatorProjectSearchEngine
|
|||
->setLabel(pht('Members'))
|
||||
->setKey('memberPHIDs')
|
||||
->setAliases(array('member', 'members')),
|
||||
id(new PhabricatorUsersSearchField())
|
||||
->setLabel(pht('Watchers'))
|
||||
->setKey('watcherPHIDs')
|
||||
->setAliases(array('watcher', 'watchers')),
|
||||
id(new PhabricatorSearchSelectField())
|
||||
->setLabel(pht('Status'))
|
||||
->setKey('status')
|
||||
|
@ -54,6 +58,10 @@ final class PhabricatorProjectSearchEngine
|
|||
$query->withMemberPHIDs($map['memberPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['watcherPHIDs']) {
|
||||
$query->withWatcherPHIDs($map['watcherPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['status']) {
|
||||
$status = idx($this->getStatusValues(), $map['status']);
|
||||
if ($status) {
|
||||
|
|
Loading…
Reference in a new issue