Permalink
Browse files

Include comment drafts in revision draft query

Summary: Previously, only inline comment drafts were included.

Test Plan:
**/differential/** - verified that there are drafts where they weren't before.

Checked executed queries.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3615
  • Loading branch information...
1 parent 12df076 commit a185b1b4a73e79ac53d4abbba06414be4405a19d vrana committed Oct 4, 2012
Showing with 29 additions and 7 deletions.
  1. +29 −7 src/applications/differential/query/DifferentialRevisionQuery.php
@@ -54,6 +54,7 @@
private $responsibles = array();
private $branches = array();
private $arcanistProjectPHIDs = array();
+ private $draftRevisions = array();
private $order = 'order-modified';
const ORDER_MODIFIED = 'order-modified';
@@ -483,6 +484,20 @@ private function loadData() {
$table = new DifferentialRevision();
$conn_r = $table->establishConnection('r');
+ if ($this->draftAuthors) {
+ $draft_key = 'differential-comment-';
+ $drafts = id(new PhabricatorDraft())->loadAllWhere(
+ 'authorPHID IN (%Ls) AND draftKey LIKE %> AND draft != %s',
+ $this->draftAuthors,
+ $draft_key,
+ '');
+ $this->draftRevisions = array();
+ $len = strlen($draft_key);
+ foreach ($drafts as $draft) {
+ $this->draftRevisions[] = substr($draft->getDraftKey(), $len);
+ }
+ }
+
$select = qsprintf(
$conn_r,
'SELECT r.* FROM %T r',
@@ -587,9 +602,11 @@ private function buildJoinsClause($conn_r) {
if ($this->draftAuthors) {
$joins[] = qsprintf(
$conn_r,
- 'JOIN %T inline_comment ON inline_comment.revisionID = r.id '.
- 'AND inline_comment.commentID is NULL',
- id(new DifferentialInlineComment())->getTableName());
+ 'LEFT JOIN %T inline_comment ON inline_comment.revisionID = r.id '.
+ 'AND inline_comment.commentID IS NULL '.
+ 'AND inline_comment.authorPHID IN (%Ls)',
+ id(new DifferentialInlineComment())->getTableName(),
+ $this->draftAuthors);
}
$joins = implode(' ', $joins);
@@ -626,10 +643,15 @@ private function buildWhereClause($conn_r) {
}
if ($this->draftAuthors) {
- $where[] = qsprintf(
- $conn_r,
- 'inline_comment.authorPHID IN (%Ls)',
- $this->draftAuthors);
+ $condition = 'inline_comment.id IS NOT NULL';
+ if ($this->draftRevisions) {
+ $condition = qsprintf(
+ $conn_r,
+ '(%Q OR r.id IN (%Ld))',
+ $condition,
+ $this->draftRevisions);
+ }
+ $where[] = $condition;
}
if ($this->revIDs) {
$where[] = qsprintf(

0 comments on commit a185b1b

Please sign in to comment.