コード例 #1
0
 public function create($statsType)
 {
     // prepare things unique to this statsType
     $ucStatsType = ucfirst($statsType);
     if (!isset($this->updateIfOlderThan[$ucStatsType])) {
         throw new Exception("unknown type of article stats type given: '{$statsType}'");
         exit;
     }
     $viewName = $this->viewNameBase . strtolower($statsType);
     $articleStatsClassName = $ucStatsType . "_ArticleStats";
     // get search results for statsTypes that need them
     $searchResults = $this->runSearch($ucStatsType);
     // setup the objects we need
     $db = new Db('https://' . AM_CRAWLER_USER . ':' . AM_CRAWLER_PW . '@' . AM_CRAWLER_DB_URL, AM_CRAWLER_DB_NAME);
     $urls = new Urls();
     $getter = new UrlGetter();
     $articleStats = new $articleStatsClassName($getter, $urls);
     $updater = new Updater($db, $this->log);
     // setup update options
     $updater->setViewName(array("crawl", $viewName));
     $updater->setArticleStats($articleStats);
     $updater->setSecondsBetweenUpdates($this->secondsBetweenDocUpdates[$ucStatsType]);
     $updater->setUpdateIfOlderThan($this->updateIfOlderThan[$ucStatsType]);
     $updater->setSearchResults($searchResults);
     return $updater;
 }