diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e5685d3268..8e3bd588ce 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -81,6 +81,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage', 'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths', 'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff', + 'ConduitAPI_differential_getrevisionfeedback_Method' => 'applications/conduit/method/differential/getrevisionfeedback', 'ConduitAPI_differential_markcommitted_Method' => 'applications/conduit/method/differential/markcommitted', 'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage', 'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty', @@ -527,6 +528,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod', + 'ConduitAPI_differential_getrevisionfeedback_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_markcommitted_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php b/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php new file mode 100644 index 0000000000..fcd351d309 --- /dev/null +++ b/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php @@ -0,0 +1,72 @@ + 'required list', + ); + } + + public function defineReturnType() { + return 'nonempty list>'; + } + + public function defineErrorTypes() { + return array( + ); + } + + protected function execute(ConduitAPIRequest $request) { + $results = array(); + $revision_ids = $request->getValue('ids'); + + if (!$revision_ids) { + return $results; + } + + $comments = id(new DifferentialComment())->loadAllWhere( + 'revisionID IN (%Ld)', + $revision_ids); + + // Helper dictionary to keep track of where the id/action pair is + // stored in results array. + $indexes = array(); + foreach ($comments as $comment) { + $action = $comment->getAction(); + $revision_id = $comment->getRevisionID(); + + if (isset($indexes[$action.$revision_id])) { + $results[$indexes[$action.$revision_id]]['count']++; + } else { + $indexes[$action.$revision_id] = count($results); + $results[] = array('id' => $revision_id, + 'action' => $action, + 'count' => 1); + } + } + + return $results; + } +} diff --git a/src/applications/conduit/method/differential/getrevisionfeedback/__init__.php b/src/applications/conduit/method/differential/getrevisionfeedback/__init__.php new file mode 100644 index 0000000000..2987d4776f --- /dev/null +++ b/src/applications/conduit/method/differential/getrevisionfeedback/__init__.php @@ -0,0 +1,15 @@ +