protected function execute($arguments = array(), $options = array()) { $stop_watch = new StopWatch(); $stop_watch->start(); logline('Started processing.'); $databaseManager = new sfDatabaseManager($this->configuration); $queries = QueryPeer::doSelect(new Criteria()); logline(sprintf("There are %s queries to process.", sizeof($queries))); foreach ($queries as $query) { $connection = Propel::getConnection(); $sql = "SELECT STD(%s) as standard_deviation FROM %s where %s=%s"; $sql = sprintf($sql, QueryResultPeer::RESULT_SIZE, QueryResultPeer::TABLE_NAME, QueryResultPeer::QUERY_ID, $query->getId()); $statement = $connection->prepareStatement($sql); $resultset = $statement->executeQuery(); $resultset->next(); $std = $resultset->getString('standard_deviation'); $sql = "SELECT AVG(%s) as mean_of_all FROM %s where %s=%s"; $sql = sprintf($sql, QueryResultPeer::RESULT_SIZE, QueryResultPeer::TABLE_NAME, QueryResultPeer::QUERY_ID, $query->getId()); $statement = $connection->prepareStatement($sql); $resultset = $statement->executeQuery(); $resultset->next(); $mean = $resultset->getString('mean_of_all'); $query->setStandardDeviation($std / $mean); logline(sprintf('Average stdev for query %s is %s.', $query->getQuery(), $query->getStandardDeviation())); $query->save(); //logLine(sprintf("Standart deviation for %s is %s.", $query->getQuery(), $deviation)); } logline(sprintf("Finished processing.")); $stop_watch->end(); logline(sprintf('Execution time: %s seconds.', $stop_watch->getTime())); logline(sprintf('!!!!!CAN RUN %s TIMES A DAY!!!!!', 24 * 60 * 60 / ($stop_watch->getTime() == 0 ? 1 : $stop_watch->getTime()))); }
protected function execute($arguments = array(), $options = array()) { $stop_watch = new StopWatch(); $stop_watch->start(); logline('Started processing.'); $searchEngine = new GoogleHitFetcher(); $databaseManager = new sfDatabaseManager($this->configuration); $queries = QueryPeer::doSelect(new Criteria()); logline(sprintf("There are %s queries to process.", sizeof($queries))); foreach ($queries as $query) { $qr = new QueryResultBulk(); $qr->setQuery($query); $result_size = $searchEngine->fetch($query->getQuery()); $qr->setResultSize($result_size); logline(sprintf("Found %s results for %s.", $result_size, $query->getQuery())); $qr->save(); } logline(sprintf("Finished processing.")); $stop_watch->end(); logline(sprintf('Execution time: %s seconds.', $stop_watch->getTime())); logline(sprintf('!!!!!CAN RUN %s TIMES A DAY!!!!!', 24 * 60 * 60 / $stop_watch->getTime())); }
public static function retrieveByQUERY($query) { $c = new Criteria(); $c->add(QueryPeer::QUERY, $query); return QueryPeer::doSelectOne($c); }
public function executeList() { $this->queries = QueryPeer::getPopularTags(100); }
public function executeStatistics($request) { $this->statistics = array('reports' => ReportPeer::doCount(new Criteria()), 'queries' => QueryPeer::doCount(new Criteria()), 'query_results' => QueryResultBulkPeer::doCount(new Criteria())); }
public function executeCloud() { $this->queries = QueryPeer::getPopularTags(); }
protected function updateObjectFromForm() { if ($this->object->getId()) { foreach ($this->object->getReportQuerys() as $report_query) { $report_query->delete(); } foreach ($this->object->getReportTags() as $tag) { $tag->delete(); } } $this->object->setTitle($this->getValue('title')); $this->object->setDescription($this->getValue('description')); $this->object->setMailFrequency($this->getValue('frequency')); if ($this->getValue('private') == 'on') { $this->object->setPublicRecord(false); } else { $this->object->setPublicRecord(true); } $tag_names = explode(',', $this->getValue('tags')); foreach ($tag_names as $tag_name) { if (!($tag_name = strtolower(trim($tag_name)))) { continue; } $tag = new ReportTag(); $tag->setName($tag_name); $this->object->addReportTag($tag); } $query_texts = explode("\n", str_replace("\r", "", $this->getValue('query_texts'))); $query_titles = explode("\n", str_replace("\r", "", $this->getValue('query_titles'))); for ($i = 0; $i < sizeof($query_texts); $i++) { $query_text = $query_texts[$i]; $query_title = $query_titles[$i]; if ($query_text) { $query = QueryPeer::retrieveByQUERY($query_text); if (!$query) { $query = new Query(); $query->setQuery($query_text); } $report_query = new ReportQuery(); $report_query->setQuery($query); $report_query->setTitle($query_title); $this->object->addReportQuery($report_query); } } if ($this->getValue('user_id')) { $this->object->setUserId($this->getValue('user_id')); } }