r114910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114909‎ | r114910 | r114911 >
Date:15:29, 14 April 2012
Author:bsitu
Status:deferred
Tags:
Comment:
followup to -r114905 - Cleanup index and make corresponding changes to the maintenance script
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/cron/updateUserMetadata.php (modified) (history)
  • /trunk/extensions/PageTriage/sql/PageTriagePage.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/PageTriage.php
@@ -115,8 +115,6 @@
116116 $updater->addExtensionTable( 'pagetriage_page_tags', $base . '/PageTriagePageTags.sql' );
117117 $updater->addExtensionTable( 'pagetriage_page', $base . '/PageTriagePage.sql' );
118118 $updater->addExtensionTable( 'pagetriage_log', $base . '/PageTriageLog.sql' );
119 - $updater->addExtensionUpdate( array( 'addField', 'pagetriage_page', 'ptrp_tags_updated',
120 - $base . '/PageTriageTimestamps.patch.sql', true ) );
121119 return true;
122120 }
123121
Index: trunk/extensions/PageTriage/sql/PageTriagePage.sql
@@ -3,9 +3,11 @@
44 ptrp_page_id int unsigned NOT NULL PRIMARY KEY,
55 ptrp_reviewed tinyint unsigned NOT NULL DEFAULT 0,
66 ptrp_deleted tinyint unsigned NOT NULL DEFAULT 0,
7 - ptrp_timestamp varbinary(14) NOT NULL
 7+ ptrp_created VARBINARY(14) NOT NULL,
 8+ ptrp_tags_updated VARBINARY(14) NOT NULL
89 ) /*$wgDBTableOptions*/;
910
10 -CREATE INDEX /*i*/ptrp_reviewed_timestamp_page_id ON /*_*/pagetriage_page (ptrp_reviewed, ptrp_timestamp, ptrp_page_id, ptrp_deleted);
11 -CREATE INDEX /*i*/ptrp_timestamp_page_id ON /*_*/pagetriage_page (ptrp_timestamp, ptrp_page_id, ptrp_deleted);
12 -CREATE INDEX /*i*/ptrp_deleted_reviewed_etc ON /*_*/pagetriage_page (ptrp_deleted, ptrp_timestamp, ptrp_page_id, ptrp_reviewed);
 11+CREATE INDEX /*i*/ptrp_reviewed_created_page_del ON /*_*/pagetriage_page (ptrp_reviewed, ptrp_created, ptrp_page_id, ptrp_deleted);
 12+CREATE INDEX /*i*/ptrp_created_page_del ON /*_*/pagetriage_page (ptrp_created, ptrp_page_id, ptrp_deleted);
 13+CREATE INDEX /*i*/ptrp_del_created_page_reviewed ON /*_*/pagetriage_page (ptrp_deleted, ptrp_created, ptrp_page_id, ptrp_reviewed);
 14+CREATE INDEX /*i*/ptrp_updated_page_reviewed ON /*_*/pagetriage_page (ptrp_tags_updated, ptrp_page_id, ptrp_reviewed);
Index: trunk/extensions/PageTriage/cron/updateUserMetadata.php
@@ -36,28 +36,37 @@
3737 $this->init();
3838 $this->output( "Started processing... \n" );
3939
40 - // Make the start time really old
41 - $startTime = wfTimestamp( TS_UNIX ) - 60 * 60 * 24 * 365 * 10;
 40+ // Scan for data updated more than a day ago
 41+ $startTime = wfTimestamp( TS_UNIX ) - 60 * 60 * 24;
4242 $count = $this->batchSize;
43 - $startId = 0;
4443
 44+ $row = $this->dbr->selectRow(
 45+ array( 'pagetriage_page' ),
 46+ array( 'MAX(ptrp_page_id) AS max_id' ),
 47+ array(),
 48+ __METHOD__
 49+ );
 50+
 51+ // No data to process, exit
 52+ if ( $row === false ) {
 53+ return;
 54+ }
 55+
 56+ $startId = $row->max_id + 1;
 57+
4558 while ( $count === $this->batchSize ) {
4659 $count = 0;
4760 $startTime = $this->dbr->addQuotes( $this->dbr->timestamp( $startTime ) );
4861
49 - // Data should expire in a day, keep this inside loop so
50 - // it's update to second
51 - $expiration = wfTimestamp( TS_UNIX ) - 60 * 60 * 24;
5262 $res = $this->dbr->select(
5363 array( 'pagetriage_page' ),
54 - array( 'ptrp_page_id', 'ptrp_created' ),
 64+ array( 'ptrp_page_id', 'ptrp_tags_updated' ),
5565 array(
56 - '(ptrp_created > ' . $startTime . ') OR
57 - (ptrp_created = ' . $startTime . ' AND ptrp_page_id > ' . $startId . ')',
58 - 'ptrp_tags_updated < ' . $this->dbr->addQuotes( $this->dbr->timestamp( $expiration ) )
 66+ '(ptrp_tags_updated < ' . $startTime . ') OR
 67+ (ptrp_tags_updated = ' . $startTime . ' AND ptrp_page_id < ' . $startId . ')'
5968 ),
6069 __METHOD__,
61 - array( 'LIMIT' => $this->batchSize, 'ORDER BY' => 'ptrp_created, ptrp_page_id' )
 70+ array( 'LIMIT' => $this->batchSize, 'ORDER BY' => 'ptrp_tags_updated DESC, ptrp_page_id DESC' )
6271 );
6372
6473 $pageId = array();
@@ -67,8 +76,10 @@
6877 }
6978
7079 if ( $pageId ) {
71 - // update the startTime with the last row
72 - $startTime = wfTimestamp( TS_UNIX, $row->ptrp_created );
 80+ // update the startTime with the last row if it's set, check in case it's not set
 81+ if ( $row->ptrp_tags_updated ) {
 82+ $startTime = wfTimestamp( TS_UNIX, $row->ptrp_tags_updated );
 83+ }
7384 $startId = $row->ptrp_page_id;
7485
7586 $acp = ArticleCompileProcessor::newFromPageId( $pageId );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r114905add cron job to update user metadatabsitu00:22, 14 April 2012

Status & tagging log