Index: trunk/extensions/PageTriage/PageTriage.php |
— | — | @@ -115,8 +115,6 @@ |
116 | 116 | $updater->addExtensionTable( 'pagetriage_page_tags', $base . '/PageTriagePageTags.sql' ); |
117 | 117 | $updater->addExtensionTable( 'pagetriage_page', $base . '/PageTriagePage.sql' ); |
118 | 118 | $updater->addExtensionTable( 'pagetriage_log', $base . '/PageTriageLog.sql' ); |
119 | | - $updater->addExtensionUpdate( array( 'addField', 'pagetriage_page', 'ptrp_tags_updated', |
120 | | - $base . '/PageTriageTimestamps.patch.sql', true ) ); |
121 | 119 | return true; |
122 | 120 | } |
123 | 121 | |
Index: trunk/extensions/PageTriage/sql/PageTriagePage.sql |
— | — | @@ -3,9 +3,11 @@ |
4 | 4 | ptrp_page_id int unsigned NOT NULL PRIMARY KEY, |
5 | 5 | ptrp_reviewed tinyint unsigned NOT NULL DEFAULT 0, |
6 | 6 | 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 |
8 | 9 | ) /*$wgDBTableOptions*/; |
9 | 10 | |
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 @@ |
37 | 37 | $this->init(); |
38 | 38 | $this->output( "Started processing... \n" ); |
39 | 39 | |
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; |
42 | 42 | $count = $this->batchSize; |
43 | | - $startId = 0; |
44 | 43 | |
| 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 | + |
45 | 58 | while ( $count === $this->batchSize ) { |
46 | 59 | $count = 0; |
47 | 60 | $startTime = $this->dbr->addQuotes( $this->dbr->timestamp( $startTime ) ); |
48 | 61 | |
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; |
52 | 62 | $res = $this->dbr->select( |
53 | 63 | array( 'pagetriage_page' ), |
54 | | - array( 'ptrp_page_id', 'ptrp_created' ), |
| 64 | + array( 'ptrp_page_id', 'ptrp_tags_updated' ), |
55 | 65 | 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 . ')' |
59 | 68 | ), |
60 | 69 | __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' ) |
62 | 71 | ); |
63 | 72 | |
64 | 73 | $pageId = array(); |
— | — | @@ -67,8 +76,10 @@ |
68 | 77 | } |
69 | 78 | |
70 | 79 | 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 | + } |
73 | 84 | $startId = $row->ptrp_page_id; |
74 | 85 | |
75 | 86 | $acp = ArticleCompileProcessor::newFromPageId( $pageId ); |