r42788 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42787‎ | r42788 | r42789 >
Date:22:36, 29 October 2008
Author:catrope
Status:old
Tags:
Comment:
CodeReview: * Fixed up list=codecomments API module added in r42781
* Added examples to all API modules
* Declaring CodeCommentsListView::$mRepo explicitly
Modified paths:
  • /trunk/extensions/CodeReview/ApiCodeComments.php (modified) (history)
  • /trunk/extensions/CodeReview/ApiCodeDiff.php (modified) (history)
  • /trunk/extensions/CodeReview/ApiCodeUpdate.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeCommentsListView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ApiCodeDiff.php
@@ -63,6 +63,12 @@
6464 'Fetch formatted diff from CodeReview\'s backing revision control system.' );
6565 }
6666
 67+ public function getExamples() {
 68+ return array(
 69+ 'api.php?action=codediff&repo=MediaWiki&rev=42080',
 70+ );
 71+ }
 72+
6773 public function getVersion() {
6874 return __CLASS__ . ': $Id$';
6975 }
Index: trunk/extensions/CodeReview/ApiCodeUpdate.php
@@ -76,6 +76,12 @@
7777 'Update CodeReview repository data from master revision control system.' );
7878 }
7979
 80+ public function getExamples() {
 81+ return array(
 82+ 'api.php?action=codeupdate&repo=MediaWiki&rev=42080',
 83+ );
 84+ }
 85+
8086 public function getVersion() {
8187 return __CLASS__ . ': $Id$';
8288 }
Index: trunk/extensions/CodeReview/CodeCommentsListView.php
@@ -2,6 +2,8 @@
33
44 // Special:Code/MediaWiki
55 class CodeCommentsListView extends CodeView {
 6+ public $mRepo;
 7+
68 function __construct( $repoName ) {
79 parent::__construct();
810 $this->mRepo = CodeRepository::newFromName( $repoName );
@@ -17,7 +19,7 @@
1820 $pager->getNavigationBar()
1921 );
2022 }
21 -
 23+
2224 function getPager() {
2325 return new CodeCommentsTablePager( $this );
2426 }
Index: trunk/extensions/CodeReview/ApiCodeComments.php
@@ -35,6 +35,8 @@
3636 $this->props = array_flip( $params['prop'] );
3737
3838 $listview = new CodeCommentsListView( $params['repo'] );
 39+ if( is_null( $listview->mRepo ) )
 40+ $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' );
3941 $pager = $listview->getPager();
4042
4143 if ( !is_null( $params['start'] ) )
@@ -48,27 +50,29 @@
4951 $data = array();
5052
5153 $count = 0;
52 - $lastTimestamp = 0; // Stop Eclipse from whining
 54+ $lastTimestamp = 0;
5355 while ( $row = $comments->fetchObject() ) {
5456 if ( $count == $limit ) {
55 - $this->setContinueEnumParameter( 'start', $lastTimestamp );
 57+ $this->setContinueEnumParameter( 'start',
 58+ wfTimestamp( TS_ISO_8601, $lastTimestamp ) );
5659 break;
5760 }
5861
59 - $data[] = self::formatRow( $row );
 62+ $data[] = $this->formatRow( $row );
6063 $lastTimestamp = $row->cc_timestamp;
6164 $count++;
6265 }
6366 $comments->free();
6467
65 - $result = $this->getMain()->getResult();
 68+ $result = $this->getResult();
6669 $result->setIndexedTagName( $data, 'comment' );
6770 $result->addValue( 'query', $this->getModuleName(), $data );
6871 }
 72+
6973 private function formatRow( $row ) {
7074 $item = array();
7175 if ( isset( $this->props['timestamp'] ) )
72 - $item['timestamp'] = $row->cc_timestamp;
 76+ $item['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cc_timestamp );
7377 if ( isset( $this->props['user'] ) )
7478 $item['user'] = $row->cc_user_text;
7579 if ( isset( $this->props['revision'] ) )
@@ -104,6 +108,26 @@
105109 );
106110 }
107111
 112+ public function getParamDescription() {
 113+ return array(
 114+ 'repo' => 'Name of the repository',
 115+ 'limit' => 'How many comments to return',
 116+ 'start' => 'Timestamp to start listing at',
 117+ 'prop' => 'Which properties to return',
 118+ );
 119+ }
 120+
 121+ public function getDescription() {
 122+ return 'List comments on revisions in CodeReview';
 123+ }
 124+
 125+ public function getExamples() {
 126+ return array(
 127+ 'api.php?action=query&list=codecomments&ccrepo=MediaWiki',
 128+ 'api.php?action=query&list=codecomments&ccrepo=MediaWiki&ccprop=timestamp|user|revision|text',
 129+ );
 130+ }
 131+
108132 public function getVersion() {
109133 return __CLASS__ . ': $Id$';
110134 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r42781Add API query module to query latest commentsbtongminh19:48, 29 October 2008

Status & tagging log