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]); } }
public function main() { print "Getting quizzes\n"; try { $gs = new GoogleSpreadsheet(); $gs->login(WH_TREBEK_GOOGLE_LOGIN, WH_TREBEK_GOOGLE_PW); $headers = $gs->getHeaders(WH_QUIZZES_GOOGLE_DOC); self::parseHeaders($headers); $quiz_data = array(); $cols = $gs->getColsWithSpaces(WH_QUIZZES_GOOGLE_DOC, 1, count($headers), 2); if (!empty($cols)) { foreach ($cols as $row) { $question_array = self::makeQuestionArray($row); if ($row[self::$quiz_name] != $last_quiz_name && $last_quiz_name != '') { //new quiz! //let's stash the old one self::saveQuizAsBlob($last_quiz_name, $last_quiz_icon, $quiz_data); $quiz_data = array(); } //add in the question $quiz_data[] = $question_array; //store last quiz name to check on next time $last_quiz_name = $row[self::$quiz_name]; $last_quiz_icon = $row[self::$quiz_icon]; } //save the final quiz self::saveQuizAsBlob($last_quiz_name, $last_quiz_icon, $quiz_data); } } catch (Exception $e) { } //send completion mail $to = new MailAddress('elizabeth@wikihow.com, allie@wikihow.com, scott@wikihow.com'); $from = new MailAddress(WH_TREBEK_GOOGLE_LOGIN); $subject = 'Quizzes processed'; $quizzes = implode(self::$import_array, "\n"); $body = "Your quizzes have completed processing. Get back to work!\n\n" . "Oh, and here they are:\n\n{$quizzes}\n"; UserMailer::send($to, $from, $subject, $body); print "Done.\n"; }
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()); } }