/** * Get pages to calculate by statistic * @return (all_id_stats => (array of stats), daily_edit_stats =>(everything edited today), ids=>(array map of stuff edited today), id_stats=>(list of stats calculated for a limited number of ids)) */ public function getPagesToCalcByStat(&$activeStats, $date) { $ret = array("all_id_stats" => TitusConfig::getBasicStats(), "daily_edit_stats" => TitusConfig::getBasicStats(), "ids" => array(), "id_stats" => TitusConfig::getBasicStats()); $dbr = $this->getTitusDB(); foreach ($activeStats as $stat => $isOn) { if ($isOn) { $statCalculator = $this->getStatClass($stat); $ids = $statCalculator->getPageIdsToCalc($dbr, $date); if (is_array($ids) && !empty($ids)) { $ret["id_stats"][$stat] = 1; $ret["ids"] = array_merge($ret["ids"], $ids); } elseif ($ids == TitusDB::DAILY_EDIT_IDS) { $ret["daily_edit_stats"][$stat] = 1; } elseif ($ids = TitusDB::ALL_IDS) { $ret["all_id_stats"][$stat] = 1; } else { throw new Exception("Return type of getPageIds from " . $stat . " was not found"); } } } $ret["ids"] = array_unique($ret["ids"]); return $ret; }
<?php require_once 'commandLine.inc'; require_once "{$IP}/extensions/wikihow/titus/Titus.class.php"; $titus = new TitusDB(true); $allStats = TitusConfig::getNightlyStats(); $allStats['Social'] = 1; $allStats['Stu'] = 0; $allStats['Photos'] = 0; $titus->calcStatsForAllPages($allStats);
<?php require_once 'commandLine.inc'; require_once "{$IP}/extensions/wikihow/titus/Titus.class.php"; $statsToCalc = TitusConfig::getDailyEditStats(); $titus = new TitusDB(true); /* $titus->calcStatsForAllPages($statsToCalc);*/ $ids = array(163806); $titus->calcStatsForPageIds($statsToCalc, $ids); /*$dailyEditStats = TitusConfig::getDailyEditStats(); $titus->calcLatestEdits($dailyEditStats);*/
private function reportErrors() { $activeStats = TitusConfig::getAllStats(); $errors = $this->titus->getErrors($activeStats); if ($errors != "") { print "Errors are " . $errors; $to = new MailAddress("gershon@wikihow.com,elizabeth@wikihow.com,reuben@wikihow.com,chris@wikihow.com"); $from = new MailAddress("*****@*****.**"); $subject = "Titus Errors"; UserMailer::send($to, $from, $subject, $errors); } }
<?php require_once 'commandLine.inc'; require_once "{$IP}/extensions/wikihow/titus/Titus.class.php"; $titus = new TitusDB(true); $stats = TitusConfig::getDailyEditStats(); $stats['RobotPolicy'] = 0; $stats['Social'] = 0; $dbr = new Database(TITUS_DB_HOST, WH_DATABASE_MAINTENANCE_USER, WH_DATABASE_MAINTENANCE_PASSWORD, TitusDB::TITUS_DB_NAME); $sql = "select ti_page_id from titus_intl where ti_language_code='{$wgLanguageCode}' AND ti_num_steps=0"; $res = $dbr->query($sql); $ids = array(); foreach ($res as $row) { $ids[] = $row->ti_page_id; } $batch = array(); foreach ($ids as $id) { $batch[] = $id; if (sizeof($batch) == 999) { $titus->calcStatsForPageIds($stats, $batch); $batch = array(); } } $titus->calcStatsForPageIds($stats, $batch);