コード例 #1
0
ファイル: dumpStuData.php プロジェクト: biribogos/wikihow-src
 /** 
  * Get a bunch of pages from STU, and put them into the database
  */
 function getPages($pages, $domain)
 {
     $ret = AdminBounceTests::doBounceQuery(array('select' => '*', 'from' => $domain, 'pages' => $pages));
     $data = $ret['results'];
     $didInsert = false;
     if (is_array($data)) {
         $sql = 'insert ignore into ' . self::STU_TABLE . '(page, domain, k, v) values';
         $first = true;
         foreach ($data as $page => $datum) {
             if (is_array($datum)) {
                 foreach ($datum as $k => $v) {
                     if ($first) {
                         $first = false;
                     } else {
                         $sql .= ",";
                     }
                     $sql .= "(" . $this->dbw->addQuotes($page) . "," . $this->dbw->addQuotes($domain) . "," . $this->dbw->addQuotes($k) . "," . $this->dbw->addQuotes($v) . ")\n";
                     $this->pagesProcessed++;
                     print $page . "\t" . $domain . "\t" . $k . "\t" . $v . "\n";
                 }
             }
         }
         // Only do insert if we have the data
         if (!$first) {
             if ($this->dryRun) {
                 print $sql;
             } else {
                 $this->dbw->query($sql, __METHOD__);
             }
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: Titus.class.php プロジェクト: ErdemA/wikihow
 public function calc(&$dbr, &$r, &$t, &$pageRow)
 {
     $stats = array('ti_stu_10s_percentage_mobile' => 0, 'ti_stu_views_mobile' => 0, 'ti_stu_10s_percentage_www' => 0, 'ti_stu_3min_percentage_www' => 0, 'ti_stu_views_www' => 0);
     $domains = array('bt' => 'www', 'mb' => 'mobile');
     foreach ($domains as $domain => $label) {
         if (IS_CLOUD_SITE) {
             $query = "select * from stu.stu_dump where domain=" . $dbr->addQuotes($domain) . " AND page=" . $dbr->addQuotes($t->getDBKey());
             $res = $dbr->query($query);
             $rets = array();
             foreach ($res as $row) {
                 $rets[$row->page][$row->k] = $row->v;
             }
             AdminBounceTests::cleanBounceData($rets);
             $stats = array_merge($stats, $this->extractStats($rets, $label));
         } else {
             $query = $this->makeQuery(&$t, $domain);
             $ret = AdminBounceTests::doBounceQuery($query);
             if (!$ret['err'] && $ret['results']) {
                 AdminBounceTests::cleanBounceData($ret['results']);
                 $stats = array_merge($stats, $this->extractStats($ret['results'], $label));
             }
         }
     }
     return $stats;
 }