示例#1
0
 public static function addSpreadsheet()
 {
     $gs = new GoogleSpreadsheet();
     $gs->login(WH_TITUS_GOOGLE_LOGIN, WH_TITUS_GOOGLE_PW);
     $cols = $gs->getCols(WH_KEYWORD_MASTER_GOOGLE_DOC, 1, 1, 2);
     foreach ($cols as $col) {
         DedupQuery::addQuery($col[0]);
     }
 }
示例#2
0
 private function getSpreadsheet(&$dbr)
 {
     global $wgLanguageCode;
     print "Getting ratings spreadsheet\n";
     try {
         $gs = new GoogleSpreadsheet();
         $gs->login(WH_TITUS_GOOGLE_LOGIN, WH_TITUS_GOOGLE_PW);
         $cols = $gs->getCols(WH_TITUS_EDITOR_GOOGLE_DOC, 1, 3, 2);
         $ids = array();
         $badDates = 0;
         foreach ($cols as $col) {
             if (is_numeric($col[0])) {
                 $output = array($this->fixDate($col[1]), $col[2]);
                 if ($output[1] == NULL) {
                     $badDates++;
                 }
                 if (isset($this->_kwl[$col[0]])) {
                     $this->reportError("Duplicate entry for article " . $col[0]);
                 }
                 $this->_kwl[$col[0]] = $output;
                 $ids[] = $col[0];
             }
         }
         if ($badDates > 100) {
             $this->reportError("Unable to parse over 100 dates in spreadsheet");
             $this->_gotSpreadsheet = true;
             $this->_badSpreadsheet = true;
             return;
         }
         if (sizeof($ids) < 1000) {
             $this->reportError("Less than 1000 ratings in ratings spreadsheet found");
             $this->_gotSpreadsheet = true;
             $this->_badSpreadsheet = true;
             return;
         }
         $this->checkForRedirects($dbr, $ids);
         $this->checkForMissing($dbr, $ids);
         $query = "select ti_page_id, ti_last_fellow_edit, ti_last_fellow_edit_timestamp FROM " . TitusDB::getDBName() . "." . TitusDB::TITUS_INTL_TABLE_NAME . " WHERE ti_language_code=" . $dbr->addquotes($wgLanguageCode);
         $res = $dbr->query($query, __METHOD__);
         $pageIds = array();
         foreach ($res as $row) {
             if (isset($this->_kwl[$row->ti_page_id])) {
                 if ($this->_kwl[$row->ti_page_id][0] != $row->ti_last_fellow_edit_timestamp || $this->_kwl[$row->ti_page_id][1] != $row->ti_last_fellow_edit) {
                     $pageIds[] = $row->ti_page_id;
                 }
             } else {
                 if ($row->ti_last_fellow_edit_timestamp != NULL && $row->ti_last_fellow_edit_timestamp != "" || $row->ti_last_fellow_edit != NULL && $row->ti_last_fellow_edit != "") {
                     $pageIds[] = $row->ti_page_id;
                 }
             }
         }
         $this->_ids = $pageIds;
         $this->_gotSpreadsheet = true;
         $this->_badSpreadsheet = false;
     } catch (Exception $e) {
         $this->_gotSpreadsheet = true;
         $this->_badSpreadsheet = true;
         $this->reportError("Problem fetching spreadsheet :" . $e->getMessage());
     }
 }