diff --git a/resources/sql/autopatches/20170320.reviewers.01.lastaction.sql b/resources/sql/autopatches/20170320.reviewers.01.lastaction.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20170320.reviewers.01.lastaction.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_differential.differential_reviewer + ADD lastActionDiffPHID VARBINARY(64); diff --git a/resources/sql/autopatches/20170320.reviewers.02.lastcomment.sql b/resources/sql/autopatches/20170320.reviewers.02.lastcomment.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20170320.reviewers.02.lastcomment.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_differential.differential_reviewer + ADD lastCommentDiffPHID VARBINARY(64); diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -718,6 +718,9 @@ break; } + + $this->markReviewerComments($object, $xactions); + return $xactions; } @@ -1836,4 +1839,59 @@ ->setNewValue($edits); } + public function getActiveDiff($object) { + if ($this->getIsNewObject()) { + return null; + } else { + return $object->getActiveDiff(); + } + } + + /** + * When a reviewer makes a comment, mark the last revision they commented + * on. + * + * This allows us to show a hint to help authors and other reviewers quickly + * distinguish between reviewers who have participated in the discussion and + * reviewers who haven't been part of it. + */ + private function markReviewerComments($object, array $xactions) { + $acting_phid = $this->getActingAsPHID(); + if (!$acting_phid) { + return; + } + + $diff = $this->getActiveDiff($object); + if (!$diff) { + return; + } + + $has_comment = false; + foreach ($xactions as $xaction) { + if ($xaction->hasComment()) { + $has_comment = true; + break; + } + } + + if (!$has_comment) { + return; + } + + $reviewer_table = new DifferentialReviewer(); + $conn = $reviewer_table->establishConnection('w'); + + queryfx( + $conn, + 'UPDATE %T SET lastCommentDiffPHID = %s + WHERE revisionPHID = %s + AND reviewerPHID = %s', + $reviewer_table->getTableName(), + $diff->getPHID(), + $object->getPHID(), + $acting_phid); + } + + + } diff --git a/src/applications/differential/storage/DifferentialReviewer.php b/src/applications/differential/storage/DifferentialReviewer.php --- a/src/applications/differential/storage/DifferentialReviewer.php +++ b/src/applications/differential/storage/DifferentialReviewer.php @@ -7,10 +7,15 @@ protected $reviewerPHID; protected $reviewerStatus; + protected $lastActionDiffPHID; + protected $lastCommentDiffPHID; + protected function getConfiguration() { return array( self::CONFIG_COLUMN_SCHEMA => array( 'reviewerStatus' => 'text64', + 'lastActionDiffPHID' => 'phid?', + 'lastCommentDiffPHID' => 'phid?', ), self::CONFIG_KEY_SCHEMA => array( 'key_revision' => array( diff --git a/src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php b/src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php --- a/src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php +++ b/src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php @@ -138,6 +138,13 @@ // Now, do the new write. if ($map) { + $diff = $this->getEditor()->getActiveDiff($revision); + if ($diff) { + $diff_phid = $diff->getPHID(); + } else { + $diff_phid = null; + } + $table = new DifferentialReviewer(); $reviewers = $table->loadAllWhere( @@ -156,6 +163,10 @@ $reviewer->setReviewerStatus($status); + if ($diff_phid) { + $reviewer->setLastActionDiffPHID($diff_phid); + } + if ($status == DifferentialReviewerStatus::STATUS_RESIGNED) { if ($reviewer->getID()) { $reviewer->delete();