Index: trunk/extensions/PageTriage/sql/PageTriageTags.sql |
— | — | @@ -25,4 +25,5 @@ |
26 | 26 | ('user_editcount', 'User total edit'), |
27 | 27 | ('user_creation_date', 'User registration date'), |
28 | 28 | ('user_autoconfirmed', 'Check if user is autoconfirmed' ), |
| 29 | +('user_bot', 'Check if user is in bot group'), |
29 | 30 | ('user_block_status', 'User block status'); |
Index: trunk/extensions/PageTriage/includes/ArticleMetadata.php |
— | — | @@ -70,6 +70,8 @@ |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Set the metadata to cache |
| 74 | + * @param $pageId int - page id |
| 75 | + * @param $singleData mixed - data to be saved |
74 | 76 | */ |
75 | 77 | protected function setMetadataToCache( $pageId, $singleData ) { |
76 | 78 | global $wgMemc; |
— | — | @@ -257,16 +259,18 @@ |
258 | 260 | |
259 | 261 | /** |
260 | 262 | * Compile article basic data like title, number of bytes |
| 263 | + * @param $metaData array |
261 | 264 | */ |
262 | 265 | protected function compileArticleBasicData( &$metaData ) { |
263 | 266 | global $wgLang; |
264 | 267 | |
265 | 268 | $dbr = wfGetDB( DB_SLAVE ); |
266 | 269 | |
| 270 | + // Article page length, creation date, number of edit, title, article triage status |
267 | 271 | $res = $dbr->select( |
268 | | - array( 'page', 'revision' ), |
269 | | - array( 'page_id', 'page_namespace', 'page_title', 'page_len', 'COUNT(rev_id) AS rev_count', 'MIN(rev_timestamp) AS creation_date' ), |
270 | | - array( 'page_id' => $this->mPageId, 'page_id = rev_page'), |
| 272 | + array( 'page', 'revision', 'pagetriage_page' ), |
| 273 | + array( 'page_id', 'page_namespace', 'page_title', 'page_len', 'COUNT(rev_id) AS rev_count', 'MIN(rev_timestamp) AS creation_date', 'ptrp_triaged' ), |
| 274 | + array( 'page_id' => $this->mPageId, 'page_id = rev_page', 'page_id = ptrp_page_id'), |
271 | 275 | __METHOD__, |
272 | 276 | array ( 'GROUP BY' => 'page_id' ) |
273 | 277 | ); |
— | — | @@ -276,6 +280,7 @@ |
277 | 281 | $metaData[$row->page_id]['creation_date'] = $row->creation_date; |
278 | 282 | $metaData[$row->page_id]['rev_count'] = $row->rev_count; |
279 | 283 | $metaData[$row->page_id]['title'] = $title->getPrefixedText(); |
| 284 | + $metaData[$row->page_id]['patrol_status'] = $row->ptrp_triaged; |
280 | 285 | } |
281 | 286 | // Remove any non-existing page_id from $this->mPageId |
282 | 287 | foreach ( $this->mPageId as $key => $pageId ) { |
— | — | @@ -287,6 +292,7 @@ |
288 | 293 | return false; |
289 | 294 | } |
290 | 295 | |
| 296 | + // Article link count |
291 | 297 | $res = $dbr->select( |
292 | 298 | array( 'page', 'pagelinks' ), |
293 | 299 | array( 'page_id', 'COUNT(pl_from) AS linkcount' ), |
— | — | @@ -298,11 +304,12 @@ |
299 | 305 | $metaData[$row->page_id]['linkcount'] = $row->linkcount; |
300 | 306 | } |
301 | 307 | foreach ( $this->mPageId as $pageId ) { |
302 | | - if ( !isset( $metaData[$row->page_id]['linkcount'] ) ) { |
303 | | - $metaData[$row->page_id]['linkcount'] = '0'; |
| 308 | + if ( !isset( $metaData[$pageId]['linkcount'] ) ) { |
| 309 | + $metaData[$pageId]['linkcount'] = '0'; |
304 | 310 | } |
305 | 311 | } |
306 | 312 | |
| 313 | + // Article category count |
307 | 314 | $res = $dbr->select( |
308 | 315 | array( 'page', 'categorylinks' ), |
309 | 316 | array( 'page_id', 'COUNT(cl_to) AS category_count' ), |
— | — | @@ -319,18 +326,15 @@ |
320 | 327 | } |
321 | 328 | } |
322 | 329 | |
| 330 | + // Article snippet |
323 | 331 | $res = $dbr->select( |
324 | | - array( 'text', 'revision', 'page', 'pagetriage_page' ), |
325 | | - array( 'page_id', 'old_text', 'ptrp_triaged' ), |
326 | | - array( 'page_id' => $this->mPageId, 'page_id = rev_page', 'rev_text_id = old_id' ), |
327 | | - __METHOD__, |
328 | | - array(), |
329 | | - array( 'pagetriage_page' => array( 'LEFT JOIN', 'page_id = ptrp_page_id' ) ) |
| 332 | + array( 'text', 'revision', 'page' ), |
| 333 | + array( 'page_id', 'old_text' ), |
| 334 | + array( 'page_id' => $this->mPageId, 'page_latest = rev_id', 'rev_text_id = old_id' ), |
| 335 | + __METHOD__ |
330 | 336 | ); |
331 | | - |
332 | 337 | foreach ( $res as $row ) { |
333 | 338 | $metaData[$row->page_id]['snippet'] = $wgLang->truncate( $row->old_text, 150 ); |
334 | | - $metaData[$row->page_id]['patrol_status'] = $row->ptrp_triaged ? $row->ptrp_triaged : '0'; |
335 | 339 | } |
336 | 340 | |
337 | 341 | return true; |
— | — | @@ -371,6 +375,7 @@ |
372 | 376 | $metaData[$row->page_id]['user_editcount'] = $user->getEditCount(); |
373 | 377 | $metaData[$row->page_id]['user_creation_date'] = wfTimestamp( TS_MW, $user->getRegistration() ); |
374 | 378 | $metaData[$row->page_id]['user_autoconfirmed'] = $user->isAllowed( 'autoconfirmed' ); |
| 379 | + $metaData[$row->page_id]['user_bot'] = $user->isAllowed( 'bot' ); |
375 | 380 | $metaData[$row->page_id]['user_block_status'] = $user->isBlocked() ? '1' : '0'; |
376 | 381 | } |
377 | 382 | } |