Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/query/DiffusionCommitQuery.php
| <?php | <?php | ||||
| final class DiffusionCommitQuery | final class DiffusionCommitQuery | ||||
| extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
| private $ids; | private $ids; | ||||
| private $phids; | private $phids; | ||||
| private $authorPHIDs; | private $authorPHIDs; | ||||
| private $defaultRepository; | private $defaultRepository; | ||||
| private $identifiers; | private $identifiers; | ||||
| private $repositoryIDs; | private $repositoryIDs; | ||||
| private $repositoryPHIDs; | private $repositoryPHIDs; | ||||
| private $identifierMap; | private $identifierMap; | ||||
| private $responsiblePHIDs; | private $responsiblePHIDs; | ||||
| private $statuses; | private $statuses; | ||||
| private $packagePHIDs; | |||||
| private $needAuditRequests; | private $needAuditRequests; | ||||
| private $auditIDs; | private $auditIDs; | ||||
| private $auditorPHIDs; | private $auditorPHIDs; | ||||
| private $epochMin; | private $epochMin; | ||||
| private $epochMax; | private $epochMax; | ||||
| private $importing; | private $importing; | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | public function withAuditorPHIDs(array $auditor_phids) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withResponsiblePHIDs(array $responsible_phids) { | public function withResponsiblePHIDs(array $responsible_phids) { | ||||
| $this->responsiblePHIDs = $responsible_phids; | $this->responsiblePHIDs = $responsible_phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withPackagePHIDs(array $package_phids) { | |||||
| $this->packagePHIDs = $package_phids; | |||||
| return $this; | |||||
| } | |||||
| public function withStatuses(array $statuses) { | public function withStatuses(array $statuses) { | ||||
| $this->statuses = $statuses; | $this->statuses = $statuses; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withAuditStatus($status) { | public function withAuditStatus($status) { | ||||
| // TODO: Replace callers with `withStatuses()`. | // TODO: Replace callers with `withStatuses()`. | ||||
| return $this->withStatuses( | return $this->withStatuses( | ||||
| ▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'commit.auditStatus IN (%Ls)', | 'commit.auditStatus IN (%Ls)', | ||||
| $this->statuses); | $this->statuses); | ||||
| } | } | ||||
| if ($this->packagePHIDs !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'package.dst IN (%Ls)', | |||||
| $this->packagePHIDs); | |||||
| } | |||||
| return $where; | return $where; | ||||
| } | } | ||||
| protected function didFilterResults(array $filtered) { | protected function didFilterResults(array $filtered) { | ||||
| if ($this->identifierMap) { | if ($this->identifierMap) { | ||||
| foreach ($this->identifierMap as $name => $commit) { | foreach ($this->identifierMap as $name => $commit) { | ||||
| if (isset($filtered[$commit->getPHID()])) { | if (isset($filtered[$commit->getPHID()])) { | ||||
| unset($this->identifierMap[$name]); | unset($this->identifierMap[$name]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private function shouldJoinAuditor() { | private function shouldJoinAuditor() { | ||||
| return ($this->auditIDs || $this->auditorPHIDs); | return ($this->auditIDs || $this->auditorPHIDs); | ||||
| } | } | ||||
| private function shouldJoinAudit() { | private function shouldJoinAudit() { | ||||
| return (bool)$this->responsiblePHIDs; | return (bool)$this->responsiblePHIDs; | ||||
| } | } | ||||
| private function shouldJoinOwners() { | |||||
| return (bool)$this->packagePHIDs; | |||||
| } | |||||
| protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | ||||
| $join = parent::buildJoinClauseParts($conn); | $join = parent::buildJoinClauseParts($conn); | ||||
| $audit_request = new PhabricatorRepositoryAuditRequest(); | $audit_request = new PhabricatorRepositoryAuditRequest(); | ||||
| if ($this->shouldJoinAuditor()) { | if ($this->shouldJoinAuditor()) { | ||||
| $join[] = qsprintf( | $join[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'JOIN %T auditor ON commit.phid = auditor.commitPHID', | 'JOIN %T auditor ON commit.phid = auditor.commitPHID', | ||||
| $audit_request->getTableName()); | $audit_request->getTableName()); | ||||
| } | } | ||||
| if ($this->shouldJoinAudit()) { | if ($this->shouldJoinAudit()) { | ||||
| $join[] = qsprintf( | $join[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'LEFT JOIN %T audit ON commit.phid = audit.commitPHID', | 'LEFT JOIN %T audit ON commit.phid = audit.commitPHID', | ||||
| $audit_request->getTableName()); | $audit_request->getTableName()); | ||||
| } | } | ||||
| if ($this->shouldJoinOwners()) { | |||||
| $join[] = qsprintf( | |||||
| $conn, | |||||
| 'JOIN %T package ON commit.phid = package.src | |||||
| AND package.type = %s', | |||||
| PhabricatorEdgeConfig::TABLE_NAME_EDGE, | |||||
| DiffusionCommitHasPackageEdgeType::EDGECONST); | |||||
| } | |||||
| return $join; | return $join; | ||||
| } | } | ||||
| protected function shouldGroupQueryResultRows() { | protected function shouldGroupQueryResultRows() { | ||||
| if ($this->shouldJoinAuditor()) { | if ($this->shouldJoinAuditor()) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| if ($this->shouldJoinAudit()) { | if ($this->shouldJoinAudit()) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| if ($this->shouldJoinOwners()) { | |||||
| return true; | |||||
| } | |||||
| return parent::shouldGroupQueryResultRows(); | return parent::shouldGroupQueryResultRows(); | ||||
| } | } | ||||
| public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
| return 'PhabricatorDiffusionApplication'; | return 'PhabricatorDiffusionApplication'; | ||||
| } | } | ||||
| public function getOrderableColumns() { | public function getOrderableColumns() { | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||