r113667 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113666‎ | r113667 | r113668 >
Date:21:14, 12 March 2012
Author:bsitu
Status:ok
Tags:
Comment:
followup to -r113451 - add documentation, pagetriage tags and fix data compilation queries
Modified paths:
  • /trunk/extensions/PageTriage/includes/ArticleMetadata.php (modified) (history)
  • /trunk/extensions/PageTriage/sql/PageTriageTags.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/sql/PageTriageTags.sql
@@ -25,4 +25,5 @@
2626 ('user_editcount', 'User total edit'),
2727 ('user_creation_date', 'User registration date'),
2828 ('user_autoconfirmed', 'Check if user is autoconfirmed' ),
 29+('user_bot', 'Check if user is in bot group'),
2930 ('user_block_status', 'User block status');
Index: trunk/extensions/PageTriage/includes/ArticleMetadata.php
@@ -70,6 +70,8 @@
7171
7272 /**
7373 * Set the metadata to cache
 74+ * @param $pageId int - page id
 75+ * @param $singleData mixed - data to be saved
7476 */
7577 protected function setMetadataToCache( $pageId, $singleData ) {
7678 global $wgMemc;
@@ -257,16 +259,18 @@
258260
259261 /**
260262 * Compile article basic data like title, number of bytes
 263+ * @param $metaData array
261264 */
262265 protected function compileArticleBasicData( &$metaData ) {
263266 global $wgLang;
264267
265268 $dbr = wfGetDB( DB_SLAVE );
266269
 270+ // Article page length, creation date, number of edit, title, article triage status
267271 $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'),
271275 __METHOD__,
272276 array ( 'GROUP BY' => 'page_id' )
273277 );
@@ -276,6 +280,7 @@
277281 $metaData[$row->page_id]['creation_date'] = $row->creation_date;
278282 $metaData[$row->page_id]['rev_count'] = $row->rev_count;
279283 $metaData[$row->page_id]['title'] = $title->getPrefixedText();
 284+ $metaData[$row->page_id]['patrol_status'] = $row->ptrp_triaged;
280285 }
281286 // Remove any non-existing page_id from $this->mPageId
282287 foreach ( $this->mPageId as $key => $pageId ) {
@@ -287,6 +292,7 @@
288293 return false;
289294 }
290295
 296+ // Article link count
291297 $res = $dbr->select(
292298 array( 'page', 'pagelinks' ),
293299 array( 'page_id', 'COUNT(pl_from) AS linkcount' ),
@@ -298,11 +304,12 @@
299305 $metaData[$row->page_id]['linkcount'] = $row->linkcount;
300306 }
301307 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';
304310 }
305311 }
306312
 313+ // Article category count
307314 $res = $dbr->select(
308315 array( 'page', 'categorylinks' ),
309316 array( 'page_id', 'COUNT(cl_to) AS category_count' ),
@@ -319,18 +326,15 @@
320327 }
321328 }
322329
 330+ // Article snippet
323331 $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__
330336 );
331 -
332337 foreach ( $res as $row ) {
333338 $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';
335339 }
336340
337341 return true;
@@ -371,6 +375,7 @@
372376 $metaData[$row->page_id]['user_editcount'] = $user->getEditCount();
373377 $metaData[$row->page_id]['user_creation_date'] = wfTimestamp( TS_MW, $user->getRegistration() );
374378 $metaData[$row->page_id]['user_autoconfirmed'] = $user->isAllowed( 'autoconfirmed' );
 379+ $metaData[$row->page_id]['user_bot'] = $user->isAllowed( 'bot' );
375380 $metaData[$row->page_id]['user_block_status'] = $user->isBlocked() ? '1' : '0';
376381 }
377382 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113451PageTriage new tables, getMetaData API and database access filebsitu02:10, 9 March 2012

Status & tagging log