r68672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68671‎ | r68672 | r68673 >
Date:18:17, 28 June 2010
Author:werdna
Status:deferred
Tags:
Comment:
ActiveStrategy: Commit some live-hacks from 1.16wmf4, and add limiting behaviour, as well as reimplementing members detection to be part of the main query
Modified paths:
  • /trunk/extensions/StrategyWiki/ActiveStrategy/ActiveStrategy_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/StrategyWiki/ActiveStrategy/ActiveStrategy_body.php
@@ -1,9 +1,15 @@
22 <?php
33
44 class ActiveStrategy {
5 - static function getTaskForces() {
 5+ static function getTaskForces( $limit ) {
66 $dbr = wfGetDB( DB_SLAVE );
77
 8+ $options = array();
 9+
 10+ if ($limit) {
 11+ $options['LIMIT'] = $limit;
 12+ }
 13+
814 $res = $dbr->select(
915 array( "page", 'categorylinks',
1016 'categorylinks as finishedcategory' ),
@@ -20,7 +26,7 @@
2127 'finishedcategory.cl_from IS NULL',
2228 ),
2329 __METHOD__,
24 - array(),
 30+ $options,
2531 array(
2632 'categorylinks' => array( 'RIGHT JOIN',
2733 array(
@@ -177,9 +183,10 @@
178184 $html = '';
179185 $db = wfGetDB( DB_MASTER );
180186 $sk = $wgUser->getSkin();
 187+ $limit = null;
181188
182189 if ( empty( $args['type'] ) ) {
183 - $args['type'] = 'taskforces';
 190+ $args['type'] = 'taskforce';
184191 }
185192
186193 $sortField = 'members';
@@ -188,15 +195,12 @@
189196 $sortField = $args['sort'];
190197 }
191198
192 - if ( $args['type'] == 'taskforces' ) {
193 - $masterPages = self::getTaskForces();
194 - } elseif ( $args['type'] == 'proposal' ) {
195 -// $masterPages = self::getProposals();
 199+ if ( isset( $args['max'] ) ) {
 200+ $limit = intval($args['max']);
196201 }
197202
198 - // Sorting by number of members doesn't require any
199 - if ($sortField == 'members' ) {
200 - return self::handleSortByMembers( $masterPages );
 203+ if ( $args['type'] == 'taskforce' ) {
 204+ $masterPages = self::getTaskForces( $limit );
201205 }
202206
203207 $tables = array( );
@@ -206,7 +210,11 @@
207211 $options = array( 'GROUP BY' => 'keyfield', 'ORDER BY' => 'value DESC' );
208212 $lookup = NULL;
209213
210 - if ( $args['type'] == 'taskforces' ) {
 214+ if ( $limit ) {
 215+ $options['LIMIT'] = intval($limit);
 216+ }
 217+
 218+ if ( $args['type'] == 'taskforce' ) {
211219 self::getTaskForcePageConditions( $masterPages, $tables, $fields,
212220 $conds, $joinConds, $lookup );
213221 } elseif( $args['type'] == 'proposal' ) {
@@ -244,10 +252,13 @@
245253 $joinConds['pagelinks'] = array( 'left join',
246254 array( 'pl_namespace=page_namespace', 'pl_title=page_title' ) );
247255 $fields[] = 'count(distinct pl_from) as value';
 256+ } elseif ( $sortField == 'members' ) {
 257+ $tables[] = 'pagelinks';
 258+ $joinConds['pagelinks'] = array( 'left join',
 259+ array( 'pl_from=page_id', 'pl_namespace' => NS_USER ) );
 260+ $fields[] = 'count(distinct pl_title) AS value';
248261 }
249262
250 -// die( $db->selectSQLText( $tables, $fields, $conds, __METHOD__, $options, $joinConds ) );
251 -
252263 $result = $db->select( $tables, $fields, $conds,
253264 __METHOD__, $options, $joinConds );
254265

Follow-up revisions

RevisionCommit summaryAuthorDate
r68674Merge r68672werdna18:18, 28 June 2010

Status & tagging log