Index: branches/wmf/1.16wmf4/extensions/StrategyWiki/ActiveStrategy/ActiveStrategy_body.php |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | } |
142 | 142 | |
143 | 143 | static function getTaskForcePageConditions( $taskForces, &$tables, &$fields, &$conds, |
144 | | - &$join_conds, &$lookup ) { |
| 144 | + &$joinConds, &$lookup ) { |
145 | 145 | $categories = array(); |
146 | 146 | foreach( $taskForces as $row ) { |
147 | 147 | $text = self::getTaskForceName( $row->tf_name ); |
— | — | @@ -159,19 +159,16 @@ |
160 | 160 | $lookup = $categories; |
161 | 161 | } |
162 | 162 | |
163 | | - static function getProposalPageConditions( $proposals, &$tables, &$fields, &$conds, |
| 163 | + static function getProposalPageConditions( &$tables, &$fields, &$conds, |
164 | 164 | &$join_conds, &$lookup ) { |
165 | 165 | $fields[] = 'page.page_title AS keyfield'; |
166 | 166 | $conds['page_namespace'] = 106; |
167 | | - $titles = array(); |
168 | | - foreach( $proposals as $row ) { |
169 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
170 | | - $titles[$row->page_title] = $title->getPrefixedText(); |
171 | | - } |
172 | 167 | |
173 | | - $conds['page_title'] = array_keys($titles); |
174 | | - |
175 | | - $lookup = $titles; |
| 168 | + $tables[] = 'categorylinks as finishedcategory'; |
| 169 | + $conds[] = 'finishedcategory.cl_from IS NULL'; |
| 170 | + $join_conds['categorylinks as finishedcategory'] = |
| 171 | + array( 'left join', array( 'cl_from=page_id', |
| 172 | + 'cl_to' => 'Archived_Done' ) ); |
176 | 173 | } |
177 | 174 | |
178 | 175 | static function getOutput( $args ) { |
— | — | @@ -194,7 +191,7 @@ |
195 | 192 | if ( $args['type'] == 'taskforces' ) { |
196 | 193 | $masterPages = self::getTaskForces(); |
197 | 194 | } elseif ( $args['type'] == 'proposal' ) { |
198 | | - $masterPages = self::getProposals(); |
| 195 | +// $masterPages = self::getProposals(); |
199 | 196 | } |
200 | 197 | |
201 | 198 | // Sorting by number of members doesn't require any |
— | — | @@ -205,15 +202,16 @@ |
206 | 203 | $tables = array( ); |
207 | 204 | $fields = array( ); |
208 | 205 | $conds = array(); |
| 206 | + $joinConds = array(); |
209 | 207 | $options = array( 'GROUP BY' => 'keyfield', 'ORDER BY' => 'value DESC' ); |
210 | | - $lookup = array(); |
| 208 | + $lookup = NULL; |
211 | 209 | |
212 | 210 | if ( $args['type'] == 'taskforces' ) { |
213 | 211 | self::getTaskForcePageConditions( $masterPages, $tables, $fields, |
214 | | - $conds, $join_conds, $lookup ); |
| 212 | + $conds, $joinConds, $lookup ); |
215 | 213 | } elseif( $args['type'] == 'proposal' ) { |
216 | | - self::getProposalPageConditions( $masterPages, $tables, $fields, |
217 | | - $conds, $join_conds, $lookup ); |
| 214 | + self::getProposalPageConditions( $tables, $fields, |
| 215 | + $conds, $joinConds, $lookup ); |
218 | 216 | } |
219 | 217 | |
220 | 218 | $tables[] = 'page'; |
— | — | @@ -228,6 +226,11 @@ |
229 | 227 | "rev_timestamp > $cutoff", |
230 | 228 | "rev_page IS NOT NULL" ) ); |
231 | 229 | $fields[] = 'count(distinct rev_id) + count(distinct thread_id) as value'; |
| 230 | + $tables[] = 'user_groups'; |
| 231 | + $joinConds['user_groups'] = array( 'left join', |
| 232 | + array( 'ug_user != 0', 'ug_user=rev_user', |
| 233 | + 'ug_group' => 'bot' ) ); |
| 234 | + $conds[] = 'ug_user IS NULL'; |
232 | 235 | |
233 | 236 | // Include LQT posts |
234 | 237 | $tables[] = 'thread'; |
— | — | @@ -243,6 +246,8 @@ |
244 | 247 | $fields[] = 'count(distinct pl_from) as value'; |
245 | 248 | } |
246 | 249 | |
| 250 | +// die( $db->selectSQLText( $tables, $fields, $conds, __METHOD__, $options, $joinConds ) ); |
| 251 | + |
247 | 252 | $result = $db->select( $tables, $fields, $conds, |
248 | 253 | __METHOD__, $options, $joinConds ); |
249 | 254 | |
— | — | @@ -250,8 +255,13 @@ |
251 | 256 | |
252 | 257 | foreach( $result as $row ) { |
253 | 258 | $number = $row->value; |
254 | | - $taskForce = $lookup[$row->keyfield]; |
| 259 | + $taskForce = $lookup ? $lookup[$row->keyfield] : $row->keyfield; |
255 | 260 | |
| 261 | + if (!$lookup && $args['type'] == 'proposal') { |
| 262 | + $title = Title::makeTitleSafe( 106, $taskForce ); |
| 263 | + $taskForce = $title->getPrefixedText(); |
| 264 | + } |
| 265 | + |
256 | 266 | if ( isset( $count[$taskForce] ) ) { |
257 | 267 | $count[$taskForce] += $number; |
258 | 268 | } else if ( $number > 0 ) { |