r114725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114724‎ | r114725 | r114726 >
Date:00:06, 5 April 2012
Author:kaldari
Status:deferred
Tags:
Comment:
adding sort direction support, getting rid of some old unused code, and various bits of clean-up
Modified paths:
  • /trunk/extensions/PageTriage/SpecialPageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/api/ApiPageTriageList.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/SpecialPageTriage.php
@@ -33,26 +33,6 @@
3434 $wgUser->saveSettings();
3535 $wgUser->invalidateCache();
3636
37 - // Initialize variable to hold list view options
38 - $opts = new FormOptions();
39 -
40 - // Set the defaults for the list view options
41 - $opts->add( 'showbots', true );
42 - $opts->add( 'showredirs', false );
43 - $opts->add( 'showtriaged', false );
44 - $opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
45 - $opts->add( 'offset', '' );
46 - $opts->add( 'namespace', '0' );
47 -
48 - // Get the option values from the page request
49 - $opts->fetchValuesFromRequest( $this->getRequest() );
50 -
51 - // Validate the data for the options
52 - $opts->validateIntBounds( 'limit', 0, 5000 );
53 -
54 - // Bind options to member variable
55 - $this->opts = $opts;
56 -
5737 // Output the title of the page
5838 $out->setPageTitle( wfMessage( 'pagetriage' ) );
5939
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
@@ -10,11 +10,6 @@
1111 // grab pageTriage statistics
1212 var stats = new mw.pageTriage.Stats( { eventBus: eventBus } );
1313
14 - // set the default sort order.
15 - articles.comparator = function( article ) {
16 - return -article.get( "creation_date" );
17 - };
18 -
1914 // overall list view
2015 // currently, this is the main application view.
2116 mw.pageTriage.ListView = Backbone.View.extend( {
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
@@ -48,12 +48,12 @@
4949 apiParams: {
5050 namespace: 0,
5151 limit: 50,
 52+ offset: 0,
 53+ dir: 'oldestfirst',
5254 /*
5355 showbots: null,
5456 showredirs: null,
5557 showtriaged: null,
56 - limit: 10,
57 - namespace: 0,
5858 no_category: 1,
5959 no_inbound_links: 1,
6060 non_autoconfirmed_users: 1,
@@ -69,7 +69,6 @@
7070
7171 url: function() {
7272 var url = mw.util.wikiScript( 'api' ) + '?action=pagetriagelist&format=json&' + $.param( this.apiParams );
73 - console.log('fetching ' + url);
7473 return url;
7574 },
7675
Index: trunk/extensions/PageTriage/api/ApiPageTriageList.php
@@ -20,15 +20,17 @@
2121 // fetch metadata for those pages
2222 $articleMetadata = new ArticleMetadata( $pages );
2323 $metaData = $articleMetadata->getMetadata();
24 -
25 - // convert this to a slightly different format that's more Backbone-friendly
26 - foreach( $metaData as $pageId => $attrs ) {
27 - $metaDataSend[] = $attrs + array( 'pageid' => $pageId );
 24+
 25+ // Sort data according to page order returned by our query. Also convert it to a
 26+ // slightly different format that's more Backbone-friendly.
 27+ $sortedMetaData = array();
 28+ foreach ( $pages as $page ) {
 29+ $sortedMetaData[] = array( 'pageid' => $page ) + $metaData[ $page ];
2830 }
2931 }
3032
3133 // Output the results
32 - $result = array( 'result' => 'success', 'pages' => $metaDataSend, 'userpagestatus' => PageTriageUtil::pageStatusForUser( $metaDataSend ) );
 34+ $result = array( 'result' => 'success', 'pages' => $sortedMetaData, 'userpagestatus' => PageTriageUtil::pageStatusForUser( $metaDataSend ) );
3335 $this->getResult()->addValue( null, $this->getModuleName(), $result );
3436 }
3537
@@ -44,7 +46,13 @@
4547 $pages = $options = array();
4648
4749 // Get the expected limit as defined in getAllowedParams
48 - $options = array( 'LIMIT' => $opts['limit'] );
 50+ $options['LIMIT'] = $opts['limit'];
 51+
 52+ if ( strtolower( $opts['dir'] ) === 'oldestfirst' ) {
 53+ $options['ORDER BY'] = 'ptrp_timestamp ASC';
 54+ } else {
 55+ $options['ORDER BY'] = 'ptrp_timestamp DESC';
 56+ }
4957
5058 // Start building the massive filter which includes meta data
5159 $tagConds = self::buildTagQuery( $opts );
@@ -102,7 +110,7 @@
103111 // no inbound links
104112 'no_inbound_links' => array( 'name' => 'linkcount', 'op' => '=', 'val' => '0' ),
105113 // non auto confirmed users
106 - 'non_auto_confirmed_users' => array( 'name' => 'user_autoconfirmed', 'op' => '=', 'val' => '0' ),
 114+ 'non_autoconfirmed_users' => array( 'name' => 'user_autoconfirmed', 'op' => '=', 'val' => '0' ),
107115 // blocked users
108116 'blocked_users' => array( 'name' => 'user_block_status', 'op' => '=', 'val' => '1' ),
109117 // show bots
@@ -137,6 +145,9 @@
138146 ApiBase::PARAM_MIN => '10',
139147 ApiBase::PARAM_TYPE => 'integer',
140148 ),
 149+ 'dir' => array(
 150+ ApiBase::PARAM_TYPE => 'string',
 151+ ),
141152 'namespace' => array(
142153 ApiBase::PARAM_DFLT => '0',
143154 ApiBase::PARAM_TYPE => 'integer',
@@ -147,7 +158,7 @@
148159 'no_inbound_links' => array(
149160 ApiBase::PARAM_TYPE => 'boolean',
150161 ),
151 - 'non_auto_confirmed_users' => array(
 162+ 'non_autoconfirmed_users' => array(
152163 ApiBase::PARAM_TYPE => 'boolean',
153164 ),
154165 'blocked_users' => array(
@@ -163,10 +174,11 @@
164175 'showredirs' => 'Whether to include redirects or not', // default is not to show redirects
165176 'showtriaged' => 'Whether to include triaged or not', // default is not to show triaged
166177 'limit' => 'The maximum number of results to return',
 178+ 'dir' => 'The direction the list should be sorted in - oldestfirst or newestfirst',
167179 'namespace' => 'What namespace to pull pages from',
168180 'no_category' => 'Whether to show only pages with no category',
169181 'no_inbound_links' => 'Whether to show only pages with no inbound links',
170 - 'non_auto_confirmed_users' => 'Whether to show only pages created by non auto confirmed users',
 182+ 'non_autoconfirmed_users' => 'Whether to show only pages created by non auto confirmed users',
171183 'blocked_users' => 'Whether to show only pages created by blocked users'
172184 );
173185 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r114772follow-up to r114725 - fixing user page statuskaldari20:50, 6 April 2012

Status & tagging log