mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 01:10:07 +00:00
backfillReadBundles.php: Use sub-select to target rows to update
UPDATE based on (user,display_hash) index Bug: T136368 Change-Id: If3348c2e663517b632c9ff3194dd4a197c74159b
This commit is contained in:
parent
9659f7283d
commit
5072e87c0b
|
@ -16,24 +16,37 @@ class BackfillReadBundles extends Maintenance {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
$dbw = MWEchoDbFactory::getDB( DB_MASTER );
|
$dbFactory = MWEchoDbFactory::newFromDefault();
|
||||||
$dbr = MWEchoDbFactory::getDB( DB_SLAVE );
|
$dbw = $dbFactory->getEchoDb( DB_MASTER );
|
||||||
|
$dbr = $dbFactory->getEchoDb( DB_SLAVE );
|
||||||
$iterator = new BatchRowIterator(
|
$iterator = new BatchRowIterator(
|
||||||
$dbr,
|
$dbr,
|
||||||
'echo_notification',
|
'echo_notification',
|
||||||
array( 'notification_event', 'notification_user' ),
|
array( 'notification_user', 'notification_event' ),
|
||||||
$this->mBatchSize
|
$this->mBatchSize
|
||||||
);
|
);
|
||||||
$iterator->setFetchColumns( array( 'notification_bundle_display_hash', 'notification_read_timestamp' ) );
|
$iterator->setFetchColumns( array( 'notification_bundle_display_hash', 'notification_read_timestamp' ) );
|
||||||
|
|
||||||
|
$unreadNonBase = $dbr->selectSQLText(
|
||||||
|
'echo_notification',
|
||||||
|
'notification_bundle_display_hash',
|
||||||
|
array(
|
||||||
|
'notification_bundle_base' => 0,
|
||||||
|
'notification_read_timestamp IS NULL',
|
||||||
|
"notification_bundle_display_hash <> ''",
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$iterator->addConditions( array(
|
$iterator->addConditions( array(
|
||||||
'notification_bundle_base' => 1,
|
'notification_bundle_base' => 1,
|
||||||
"notification_bundle_display_hash <>'' ",
|
|
||||||
'notification_read_timestamp IS NOT NULL',
|
'notification_read_timestamp IS NOT NULL',
|
||||||
|
"notification_bundle_display_hash IN ( $unreadNonBase )",
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$processed = 0;
|
$processed = 0;
|
||||||
foreach ( $iterator as $batch ) {
|
foreach ( $iterator as $batch ) {
|
||||||
foreach ( $batch as $row ) {
|
foreach ( $batch as $row ) {
|
||||||
|
$userId = $row->notification_user;
|
||||||
$displayHash = $row->notification_bundle_display_hash;
|
$displayHash = $row->notification_bundle_display_hash;
|
||||||
$readTimestamp = $row->notification_read_timestamp;
|
$readTimestamp = $row->notification_read_timestamp;
|
||||||
|
|
||||||
|
@ -41,9 +54,10 @@ class BackfillReadBundles extends Maintenance {
|
||||||
'echo_notification',
|
'echo_notification',
|
||||||
array( 'notification_read_timestamp' => $readTimestamp ),
|
array( 'notification_read_timestamp' => $readTimestamp ),
|
||||||
array(
|
array(
|
||||||
'notification_read_timestamp IS NULL',
|
'notification_user' => $userId,
|
||||||
'notification_bundle_base' => 0,
|
|
||||||
'notification_bundle_display_hash' => $displayHash,
|
'notification_bundle_display_hash' => $displayHash,
|
||||||
|
'notification_bundle_base' => 0,
|
||||||
|
'notification_read_timestamp IS NULL',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -55,6 +69,7 @@ class BackfillReadBundles extends Maintenance {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->output( "Updated $processed notifications.\n" );
|
$this->output( "Updated $processed notifications.\n" );
|
||||||
|
$dbFactory->waitForSlaves();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue