Index: branches/wmf/1.16wmf4/extensions/StrategyWiki/ActiveStrategy/ActiveStrategy_body.php |
— | — | @@ -22,6 +22,11 @@ |
23 | 23 | static function formatResult( $skin, $taskForce, $number, $type ) { |
24 | 24 | global $wgContLang, $wgLang, $wgActiveStrategyColors; |
25 | 25 | |
| 26 | + if ( ! $taskForce ) { |
| 27 | + // Fail. |
| 28 | + return; |
| 29 | + } |
| 30 | + |
26 | 31 | $title = Title::newFromText( $taskForce ); |
27 | 32 | $text = $wgContLang->convert( $title->getPrefixedText() ); |
28 | 33 | $text = self::getTaskForceName( $text ); |
— | — | @@ -94,7 +99,7 @@ |
95 | 100 | $tables = array( 'page', 'categorylinks' ); |
96 | 101 | $fields = array( 'categorylinks.cl_to' ); |
97 | 102 | $conds = array( 'categorylinks.cl_to' => $categories ); |
98 | | - $options = array( 'GROUP BY' => 'categorylinks.cl_to' ); |
| 103 | + $options = array( 'GROUP BY' => 'categorylinks.cl_to', 'ORDER BY' => 'value DESC' ); |
99 | 104 | $joinConds = array( 'categorylinks' => |
100 | 105 | array( 'left join', 'categorylinks.cl_from=page.page_id' ) ); |
101 | 106 | |
— | — | @@ -121,12 +126,13 @@ |
122 | 127 | $conds[] = 'finishedcategory.cl_from IS NULL'; |
123 | 128 | |
124 | 129 | if ( $sortField == 'edits' ) { |
| 130 | + $cutoff = $db->timestamp( time() - $wgActiveStrategyPeriod ); |
| 131 | + $cutoff = $db->addQuotes( $cutoff ); |
125 | 132 | $tables[] = 'revision'; |
126 | 133 | $joinConds['revision'] = |
127 | | - array( 'left join', 'rev_page=page_id' ); |
| 134 | + array( 'left join', |
| 135 | + array( 'rev_page=page_id', "rev_timestamp > $cutoff" ) ); |
128 | 136 | $fields[] = 'count(distinct rev_id) as value'; |
129 | | - $cutoff = $db->timestamp( time() - $wgActiveStrategyPeriod ); |
130 | | - $conds[] = "rev_timestamp > $cutoff"; |
131 | 137 | } elseif ( $sortField == 'ranking' ) { |
132 | 138 | $tables[] = 'pagelinks'; |
133 | 139 | $joinConds['pagelinks'] = array( 'left join', |
— | — | @@ -137,6 +143,7 @@ |
138 | 144 | $result = $db->select( $tables, $fields, $conds, |
139 | 145 | __METHOD__, $options, $joinConds ); |
140 | 146 | |
| 147 | + |
141 | 148 | $categoryToTaskForce = array_flip( $categories ); |
142 | 149 | |
143 | 150 | foreach( $result as $row ) { |
— | — | @@ -147,6 +154,8 @@ |
148 | 155 | } |
149 | 156 | |
150 | 157 | $html = Xml::tags( 'ul', null, $html ); |
| 158 | + $html .= "<!-- " . $db->selectSQLText( $tables, $fields, $conds, __METHOD__, |
| 159 | + $options, $joinConds ) . '-->'; |
151 | 160 | |
152 | 161 | return $html; |
153 | 162 | } |