Differential D21214 Diff 50527 src/applications/differential/query/DifferentialInlineCommentQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/query/DifferentialInlineCommentQuery.php
Show All 10 Lines | final class DifferentialInlineCommentQuery | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $drafts; | private $drafts; | ||||
private $authorPHIDs; | private $authorPHIDs; | ||||
private $revisionPHIDs; | private $revisionPHIDs; | ||||
private $deletedDrafts; | private $deletedDrafts; | ||||
private $needHidden; | private $needHidden; | ||||
private $withEmpty; | |||||
public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getViewer() { | public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
Show All 29 Lines | public function withDeletedDrafts($deleted_drafts) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needHidden($need) { | public function needHidden($need) { | ||||
$this->needHidden = $need; | $this->needHidden = $need; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withEmptyInlineComments($empty) { | |||||
$this->withEmpty = $empty; | |||||
return $this; | |||||
} | |||||
public function execute() { | public function execute() { | ||||
$table = new DifferentialTransactionComment(); | $table = new DifferentialTransactionComment(); | ||||
$conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
$data = queryfx_all( | $data = queryfx_all( | ||||
$conn_r, | $conn_r, | ||||
'SELECT * FROM %T %Q %Q', | 'SELECT * FROM %T %Q %Q', | ||||
$table->getTableName(), | $table->getTableName(), | ||||
$this->buildWhereClause($conn_r), | $this->buildWhereClause($conn_r), | ||||
$this->buildLimitClause($conn_r)); | $this->buildLimitClause($conn_r)); | ||||
$comments = $table->loadAllFromArray($data); | $comments = $table->loadAllFromArray($data); | ||||
if ($this->withEmpty !== null) { | |||||
$want_empty = (bool)$this->withEmpty; | |||||
foreach ($comments as $key => $value) { | |||||
if ($value->isEmptyInlineComment() !== $want_empty) { | |||||
unset($comments[$key]); | |||||
} | |||||
} | |||||
} | |||||
if ($this->needHidden) { | if ($this->needHidden) { | ||||
$viewer_phid = $this->getViewer()->getPHID(); | $viewer_phid = $this->getViewer()->getPHID(); | ||||
if ($viewer_phid && $comments) { | if ($viewer_phid && $comments) { | ||||
$hidden = queryfx_all( | $hidden = queryfx_all( | ||||
$conn_r, | $conn_r, | ||||
'SELECT commentID FROM %T WHERE userPHID = %s | 'SELECT commentID FROM %T WHERE userPHID = %s | ||||
AND commentID IN (%Ls)', | AND commentID IN (%Ls)', | ||||
id(new DifferentialHiddenComment())->getTableName(), | id(new DifferentialHiddenComment())->getTableName(), | ||||
▲ Show 20 Lines • Show All 399 Lines • Show Last 20 Lines |