public function execute() { if (!$this->invalidEventType) { $this->output("There is nothing to process\n"); return; } global $wgEchoCluster; $dbw = MWEchoDbFactory::getDB(DB_MASTER); $dbr = MWEchoDbFactory::getDB(DB_SLAVE); $count = $this->batchSize; while ($count == $this->batchSize) { $res = $dbr->select(array('echo_event'), array('event_id'), array('event_type' => $this->invalidEventType), __METHOD__, array('LIMIT' => $this->batchSize)); $event = array(); $count = 0; foreach ($res as $row) { if (!in_array($row->event_id, $event)) { $event[] = $row->event_id; } $count++; } if ($event) { $dbw->begin(); $dbw->delete('echo_event', array('event_id' => $event), __METHOD__); $dbw->delete('echo_notification', array('notification_event' => $event), __METHOD__); $dbw->commit(); $this->output("processing " . count($event) . " invalid events\n"); wfWaitForSlaves(false, false, $wgEchoCluster); } // Cleanup is not necessary for // 1. echo_email_batch, invalid notification is removed during the cron } }
public function execute() { global $wgEchoCluster; $reader = new EchoBatchRowIterator(MWEchoDbFactory::getDB(DB_SLAVE), $this->table, $this->idField, $this->mBatchSize); $reader->addConditions(array("event_page_title IS NOT NULL", "event_page_id" => null)); $updater = new EchoBatchRowUpdate($reader, new EchoBatchRowWriter(MWEchoDbFactory::getDB(DB_MASTER), $this->table, $wgEchoCluster), new EchoSuppressionRowUpdateGenerator()); $updater->setOutput(array($this, '__internalOutput')); $updater->execute(); }
/** * Clear processed events from the queue */ protected function clearProcessedEvent() { if (!$this->baseEvent) { return; } $conds = array('eeb_user_id' => $this->mUser->getId(), 'eeb_event_hash' => $this->bundleHash); $conds[] = 'eeb_event_id <= ' . intval($this->baseEvent->getId()); $dbw = MWEchoDbFactory::getDB(DB_MASTER); $dbw->delete('echo_email_batch', $conds, __METHOD__, array()); }
/** * Get a list of users to be notified for the batch * @param $startUserId int * @param $batchSize int */ public static function actuallyGetUsersToNotify($startUserId, $batchSize) { $dbr = MWEchoDbFactory::getDB(DB_SLAVE); $res = $dbr->select(array('echo_email_batch'), array('eeb_user_id'), array('eeb_user_id > ' . $startUserId), __METHOD__, array('ORDER BY' => 'eeb_user_id', 'LIMIT' => $batchSize)); return $res; }
/** * IMPORTANT: should only call this function if the number of unread notification * is reasonable, for example, unread notification count is less than the max * display defined in $wgEchoMaxNotificationCount * @param $user User * @param $type string * @return array */ public function getUnreadNotifications($user, $type) { //XXCHANGEDXX - allow anons [sc|rs] $dbr = MWEchoDbFactory::getDB(DB_SLAVE); $res = $dbr->select(array('echo_notification', 'echo_event'), array('notification_event'), array('notification_user' => $user->getId(), 'notification_bundle_base' => 1, 'notification_read_timestamp' => null, 'event_type' => $type, 'notification_event = event_id') + ($user->isAnon() ? array('notification_anon_ip' => $user->getName()) : array()), __METHOD__); $eventIds = array(); foreach ($res as $row) { $eventIds[$row->notification_event] = $row->notification_event; } return $eventIds; }
public function setUp() { parent::setUp(); $this->dbr = MWEchoDbFactory::getDB(DB_SLAVE); }