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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user