Exemplo n.º 1
0
 /** 
  * 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;
 }
Exemplo n.º 2
0
 private function calcAccuracy()
 {
     echo "calcAccuracy start: " . wfTimestampNow() . "\n";
     $accuracyStats = TitusConfig::getBasicStats();
     $accuracyStats['Title'] = 0;
     $accuracyStats['Accuracy'] = 1;
     $lowDate = wfTimestamp(TS_MW, strtotime("-1 day", strtotime(date('Ymd', time()))));
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('rating', 'distinct rat_page', array("rat_timestamp >= '{$lowDate}'"), __METHOD__);
     $ids = array();
     foreach ($res as $row) {
         $ids[] = $row->rat_page;
     }
     if (!empty($ids)) {
         $pageChunks = array_chunk($ids, 1000);
         foreach ($pageChunks as $chunk) {
             $this->titus->calcStatsForPageIds($accuracyStats, $chunk);
         }
     }
     echo "calcAccuracy finish: " . wfTimestampNow() . "\n";
 }
Exemplo n.º 3
0
<?php

require_once 'commandLine.inc';
require_once "{$IP}/extensions/wikihow/titus/Titus.class.php";
$statsToCalc = TitusConfig::getBasicStats();
$statsToCalc['Title'] = 0;
$statsToCalc['Accuracy'] = 1;
$statsToCalc['Templates'] = 1;
$titus = new TitusDB(true);
/*
$titus->calcStatsForAllPages($statsToCalc);
$ids = array(1132186,1126217,722887,510006);
$titus->calcStatsForPageIds($statsToCalc, $ids);
*/
$dailyEditStats = TitusConfig::getDailyEditStats();
$titus->calcLatestEdits($dailyEditStats);