$usersCount = $usersList->numRows(); echo ": {$usersCount} user(s) have unwanted Blog Post badges\n\n"; if ($usersCount) { echo "Removing the badges\n\n"; $dbw->delete('ach_user_badges', $queryBadgeFilters); echo "Recalculating user score and counters:\n\n"; while ($currentUser = $dbw->fetchObject($usersList)) { echo "\t* Processing user {$currentUser->user_id}\n"; $userCounters = $dbw->select('ach_user_counters', array('data'), array('user_id' => $currentUser->user_id)); if ($row = $dbw->fetchObject($userCounters)) { $counters = unserialize($row->data); foreach ($counters as $wikiId => $data) { $data[BADGE_BLOGPOST] = 1; $wgCityId = $wikiId; echo "\t\t- Recalculating user counters for Wiki ID {$wikiId}\n"; $userCountersService = new AchUserCountersService($currentUser->user_id); $userCountersService->setCounters($data); $userCountersService->save(); echo "\t\t- Recalculating user score for Wiki ID {$wikiId}\n\n"; $awardingService = new AchAwardingService(); $awardingService->migration($currentUser->user_id); } } else { echo '\\t\\tError, this user has no counters!'; } } $dbw->commit(); echo "\nDone\n"; } else { echo "Nothing to do\n"; }
$dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); $dbw->insert('ach_user_badges', $badgesToInsert); sleep(1); /* * CONUTERS */ $dbr = wfGetDB(DB_MASTER); $res = $dbr->query("select * from achievements_counters"); while ($row = $dbr->fetchObject($res)) { $counter = array(); $counter['user_id'] = $row->user_id; $counter['data'] = array(); $data = unserialize($row->data); foreach ($data as $counter_key => $counter_value) { if ($counter_key == 6) { $counter_value_new = array(1 => $counter_value['counter'], 2 => $counter_value['date']); } else { if ($counter_key == 13) { $counter_value_new = array(1 => $counter_value['counter'], 2 => $counter_value['date']); } else { $counter_value_new = $counter_value; } } $counter['data'][-1 * $counter_key] = $counter_value_new; } $userCountersService = new AchUserCountersService($counter['user_id']); $userCountersService->setCounters($counter['data']); $userCountersService->save(); $awardingService = new AchAwardingService(); $awardingService->migration($counter['user_id']); }
private function loadOwnerCounters() { wfProfileIn(__METHOD__); $userCountersService = new AchUserCountersService($this->mUserOwner->getID()); $this->mOwnerCounters = $userCountersService->getCounters(); wfProfileOut(__METHOD__); }
public function getCounters() { if (!isset($this->counters)) { $countersService = new AchUserCountersService($this->getId()); $this->counters = $countersService->getCounters(); } return $this->counters; }