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

Simplify selection of inline comments from RevisionView

Summary: Ref T2222. Currently, we load inline comments by `commentID` here, but we always pass every commentID associated with the revision. Instead, just load non-draft comments by revision ID. This simplifies querying a little bit and is likely faster anyway (draft comments are currently loaded separately).

Test Plan: Looked at some revisions and verified inlines showed up correctly and in the right places.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

Differential Revision: https://secure.phabricator.com/D6270
This commit is contained in:
epriestley 2013-06-24 11:01:51 -07:00
parent 3124838d65
commit 7c2f6f8361
2 changed files with 8 additions and 21 deletions

View file

@ -80,7 +80,9 @@ final class DifferentialRevisionViewController extends DifferentialController {
$comments);
$all_changesets = $changesets;
$inlines = $this->loadInlineComments($comments, $all_changesets);
$inlines = $this->loadInlineComments(
$revision,
$all_changesets);
$object_phids = array_merge(
$revision->getReviewers(),
@ -629,19 +631,16 @@ final class DifferentialRevisionViewController extends DifferentialController {
return $actions_dict;
}
private function loadInlineComments(array $comments, array &$changesets) {
assert_instances_of($comments, 'DifferentialComment');
private function loadInlineComments(
DifferentialRevision $revision,
array &$changesets) {
assert_instances_of($changesets, 'DifferentialChangeset');
$inline_comments = array();
$comment_ids = array_filter(mpull($comments, 'getID'));
if (!$comment_ids) {
return $inline_comments;
}
$inline_comments = id(new DifferentialInlineCommentQuery())
->withCommentIDs($comment_ids)
->withRevisionIDs(array($revision->getID()))
->withNotDraft(true)
->execute();
$load_changesets = array();

View file

@ -30,11 +30,6 @@ final class DifferentialInlineCommentQuery
return $this;
}
public function withCommentIDs(array $ids) {
$this->commentIDs = $ids;
return $this;
}
public function withViewerAndChangesetIDs($author_phid, array $ids) {
$this->viewerAndChangesetIDs = array($author_phid, $ids);
return $this;
@ -91,13 +86,6 @@ final class DifferentialInlineCommentQuery
$this->ids);
}
if ($this->commentIDs) {
$where[] = qsprintf(
$conn_r,
'commentID in (%Ld)',
$this->commentIDs);
}
if ($this->viewerAndChangesetIDs) {
list($phid, $ids) = $this->viewerAndChangesetIDs;
$where[] = qsprintf(